# by configure)
deprecated_h_sources = \
+ deprecated/gtkactivatable.h \
+ deprecated/gtkaction.h \
+ deprecated/gtkactiongroup.h \
deprecated/gtkcolorsel.h \
deprecated/gtkcolorseldialog.h \
deprecated/gtkfontsel.h \
deprecated/gtkhscrollbar.h \
deprecated/gtkhseparator.h \
deprecated/gtkhsv.h \
+ deprecated/gtkiconfactory.h \
+ deprecated/gtkimagemenuitem.h \
+ deprecated/gtkradioaction.h \
deprecated/gtkrc.h \
+ deprecated/gtkrecentaction.h \
+ deprecated/gtkstock.h \
deprecated/gtkstyle.h \
deprecated/gtksymboliccolor.h \
deprecated/gtktable.h \
deprecated/gtktearoffmenuitem.h \
+ deprecated/gtktoggleaction.h \
+ deprecated/gtkuimanager.h \
deprecated/gtkvbbox.h \
deprecated/gtkvbox.h \
deprecated/gtkvscale.h \
gtkaccelmap.h \
gtkaccessible.h \
gtkactionable.h \
- gtkaction.h \
- gtkactiongroup.h \
- gtkactivatable.h \
gtkadjustment.h \
gtkalignment.h \
gtkappchooser.h \
gtkframe.h \
gtkgrid.h \
gtkheaderbar.h \
- gtkiconfactory.h \
gtkicontheme.h \
gtkiconview.h \
gtkimage.h \
- gtkimagemenuitem.h \
gtkimcontext.h \
gtkimcontextinfo.h \
gtkimcontextsimple.h \
gtkprintoperationpreview.h \
gtkprintsettings.h \
gtkprogressbar.h \
- gtkradioaction.h \
gtkradiobutton.h \
gtkradiomenuitem.h \
gtkradiotoolbutton.h \
gtkrange.h \
- gtkrecentaction.h \
gtkrecentchooser.h \
gtkrecentchooserdialog.h \
gtkrecentchoosermenu.h \
gtkstackswitcher.h \
gtkstatusbar.h \
gtkstatusicon.h \
- gtkstock.h \
gtkstylecontext.h \
gtkstyleproperties.h \
gtkstyleprovider.h \
gtktexttagtable.h \
gtktextview.h \
gtkthemingengine.h \
- gtktoggleaction.h \
gtktogglebutton.h \
gtktoggletoolbutton.h \
gtktoolbar.h \
gtktreeview.h \
gtktreeviewcolumn.h \
gtktypes.h \
- gtkuimanager.h \
gtkviewport.h \
gtkvolumebutton.h \
gtkwidget.h \
# GTK+ C sources to build the library from
deprecated_c_sources = \
+ deprecated/gtkactivatable.c \
+ deprecated/gtkaction.c \
+ deprecated/gtkactiongroup.c \
deprecated/gtkcolorsel.c \
deprecated/gtkcolorseldialog.c \
deprecated/gtkfontsel.c \
deprecated/gtkhscrollbar.c \
deprecated/gtkhseparator.c \
deprecated/gtkhsv.c \
+ deprecated/gtkiconfactory.c \
+ deprecated/gtkimagemenuitem.c \
+ deprecated/gtkradioaction.c \
deprecated/gtkrc.c \
+ deprecated/gtkrecentaction.c \
+ deprecated/gtkstock.c \
deprecated/gtkstyle.c \
deprecated/gtksymboliccolor.c \
deprecated/gtktable.c \
deprecated/gtktearoffmenuitem.c \
+ deprecated/gtktoggleaction.c \
+ deprecated/gtkuimanager.c \
deprecated/gtkvbbox.c \
deprecated/gtkvbox.c \
deprecated/gtkvscale.c \
gtkaccellabel.c \
gtkaccelmap.c \
gtkaccessible.c \
- gtkaction.c \
gtkactionhelper.c \
- gtkactiongroup.c \
- gtkactivatable.c \
gtkadjustment.c \
gtkalignment.c \
gtkallocatedbitmask.c \
gtkhsla.c \
gtkiconcache.c \
gtkiconcachevalidator.c \
- gtkiconfactory.c \
gtkiconhelper.c \
gtkicontheme.c \
gtkiconview.c \
gtkimage.c \
- gtkimagemenuitem.c \
gtkimcontext.c \
gtkimcontextsimple.c \
gtkimmodule.c \
gtkprivatetypebuiltins.c \
gtkprogressbar.c \
gtkpixelcache.c \
- gtkradioaction.c \
gtkradiobutton.c \
gtkradiomenuitem.c \
gtkradiotoolbutton.c \
gtkrange.c \
gtkrbtree.c \
- gtkrecentaction.c \
gtkrecentchooserdefault.c \
gtkrecentchooserdialog.c \
gtkrecentchoosermenu.c \
gtkstackswitcher.c \
gtkstatusbar.c \
gtkstatusicon.c \
- gtkstock.c \
gtkstyleanimation.c \
gtkstylecascade.c \
gtkstylecontext.c \
gtktextview.c \
gtkthemingbackground.c \
gtkthemingengine.c \
- gtktoggleaction.c \
gtktogglebutton.c \
gtktoggletoolbutton.c \
gtktoolbar.c \
gtktreeview.c \
gtktreeviewcolumn.c \
gtktypebuiltins.c \
- gtkuimanager.c \
gtkvolumebutton.c \
gtkviewport.c \
gtkwidget.c \
--- /dev/null
+/*
+ * GTK - The GIMP Toolkit
+ * Copyright (C) 1998, 1999 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Author: James Henstridge <james@daa.com.au>
+ *
+ * Modified by the GTK+ Team and others 2003. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+/**
+ * SECTION:gtkaction
+ * @Short_description: An action which can be triggered by a menu or toolbar item
+ * @Title: GtkAction
+ * @See_also: #GtkActionGroup, #GtkUIManager, #GtkActivatable
+ *
+ * Actions represent operations that the user can be perform, along with
+ * some information how it should be presented in the interface. Each action
+ * provides methods to create icons, menu items and toolbar items
+ * representing itself.
+ *
+ * As well as the callback that is called when the action gets activated,
+ * the following also gets associated with the action:
+ * <itemizedlist>
+ * <listitem><para>a name (not translated, for path lookup)</para></listitem>
+ * <listitem><para>a label (translated, for display)</para></listitem>
+ * <listitem><para>an accelerator</para></listitem>
+ * <listitem><para>whether label indicates a stock id</para></listitem>
+ * <listitem><para>a tooltip (optional, translated)</para></listitem>
+ * <listitem><para>a toolbar label (optional, shorter than label)</para></listitem>
+ * </itemizedlist>
+ * The action will also have some state information:
+ * <itemizedlist>
+ * <listitem><para>visible (shown/hidden)</para></listitem>
+ * <listitem><para>sensitive (enabled/disabled)</para></listitem>
+ * </itemizedlist>
+ * Apart from regular actions, there are <link linkend="GtkToggleAction">toggle
+ * actions</link>, which can be toggled between two states and <link
+ * linkend="GtkRadioAction">radio actions</link>, of which only one in a group
+ * can be in the "active" state. Other actions can be implemented as #GtkAction
+ * subclasses.
+ *
+ * Each action can have one or more proxy widgets. To act as an action proxy,
+ * widget needs to implement #GtkActivatable interface. Proxies mirror the state
+ * of the action and should change when the action's state changes. Properties
+ * that are always mirrored by proxies are #GtkAction:sensitive and
+ * #GtkAction:visible. #GtkAction:gicon, #GtkAction:icon-name, #GtkAction:label,
+ * #GtkAction:short-label and #GtkAction:stock-id properties are only mirorred
+ * if proxy widget has #GtkActivatable:use-action-appearance property set to
+ * %TRUE.
+ *
+ * When the proxy is activated, it should activate its action.
+ */
+
+#include "config.h"
+
+#define GDK_DISABLE_DEPRECATION_WARNINGS
+
+#include "gtkaction.h"
+#include "gtkactiongroup.h"
+#include "gtkaccellabel.h"
+#include "gtkbutton.h"
+#include "gtkiconfactory.h"
+#include "gtkimage.h"
+#include "gtkimagemenuitem.h"
+#include "gtkintl.h"
+#include "gtklabel.h"
+#include "gtkmarshalers.h"
+#include "gtkmenuitem.h"
+#include "gtkstock.h"
+#include "deprecated/gtktearoffmenuitem.h"
+#include "gtktoolbutton.h"
+#include "gtktoolbar.h"
+#include "gtkprivate.h"
+#include "gtkbuildable.h"
+#include "gtkactivatable.h"
+
+
+struct _GtkActionPrivate
+{
+ const gchar *name; /* interned */
+ gchar *label;
+ gchar *short_label;
+ gchar *tooltip;
+ gchar *stock_id; /* stock icon */
+ gchar *icon_name; /* themed icon */
+ GIcon *gicon;
+
+ guint sensitive : 1;
+ guint visible : 1;
+ guint label_set : 1; /* these two used so we can set label */
+ guint short_label_set : 1; /* based on stock id */
+ guint visible_horizontal : 1;
+ guint visible_vertical : 1;
+ guint is_important : 1;
+ guint hide_if_empty : 1;
+ guint visible_overflown : 1;
+ guint always_show_image : 1;
+ guint recursion_guard : 1;
+ guint activate_blocked : 1;
+
+ /* accelerator */
+ guint accel_count;
+ GtkAccelGroup *accel_group;
+ GClosure *accel_closure;
+ GQuark accel_quark;
+
+ GtkActionGroup *action_group;
+
+ /* list of proxy widgets */
+ GSList *proxies;
+};
+
+enum
+{
+ ACTIVATE,
+ LAST_SIGNAL
+};
+
+enum
+{
+ PROP_0,
+ PROP_NAME,
+ PROP_LABEL,
+ PROP_SHORT_LABEL,
+ PROP_TOOLTIP,
+ PROP_STOCK_ID,
+ PROP_ICON_NAME,
+ PROP_GICON,
+ PROP_VISIBLE_HORIZONTAL,
+ PROP_VISIBLE_VERTICAL,
+ PROP_VISIBLE_OVERFLOWN,
+ PROP_IS_IMPORTANT,
+ PROP_HIDE_IF_EMPTY,
+ PROP_SENSITIVE,
+ PROP_VISIBLE,
+ PROP_ACTION_GROUP,
+ PROP_ALWAYS_SHOW_IMAGE
+};
+
+/* GtkBuildable */
+static void gtk_action_buildable_init (GtkBuildableIface *iface);
+static void gtk_action_buildable_set_name (GtkBuildable *buildable,
+ const gchar *name);
+static const gchar* gtk_action_buildable_get_name (GtkBuildable *buildable);
+
+G_DEFINE_TYPE_WITH_CODE (GtkAction, gtk_action, G_TYPE_OBJECT,
+ G_ADD_PRIVATE (GtkAction)
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
+ gtk_action_buildable_init))
+
+static void gtk_action_finalize (GObject *object);
+static void gtk_action_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gtk_action_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gtk_action_set_action_group (GtkAction *action,
+ GtkActionGroup *action_group);
+
+static GtkWidget *create_menu_item (GtkAction *action);
+static GtkWidget *create_tool_item (GtkAction *action);
+static void connect_proxy (GtkAction *action,
+ GtkWidget *proxy);
+static void disconnect_proxy (GtkAction *action,
+ GtkWidget *proxy);
+
+static void closure_accel_activate (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+static guint action_signals[LAST_SIGNAL] = { 0 };
+
+
+static void
+gtk_action_class_init (GtkActionClass *klass)
+{
+ GObjectClass *gobject_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+
+ gobject_class->finalize = gtk_action_finalize;
+ gobject_class->set_property = gtk_action_set_property;
+ gobject_class->get_property = gtk_action_get_property;
+
+ klass->activate = NULL;
+
+ klass->create_menu_item = create_menu_item;
+ klass->create_tool_item = create_tool_item;
+ klass->create_menu = NULL;
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+ klass->menu_item_type = GTK_TYPE_IMAGE_MENU_ITEM;
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+ klass->toolbar_item_type = GTK_TYPE_TOOL_BUTTON;
+ klass->connect_proxy = connect_proxy;
+ klass->disconnect_proxy = disconnect_proxy;
+
+ /**
+ * GtkAction:name:
+ *
+ * A unique name for the action.
+ *
+ * Deprecated: 3.10
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_NAME,
+ g_param_spec_string ("name",
+ P_("Name"),
+ P_("A unique name for the action."),
+ NULL,
+ GTK_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ /**
+ * GtkAction:label:
+ *
+ * The label used for menu items and buttons that activate
+ * this action. If the label is %NULL, GTK+ uses the stock
+ * label specified via the stock-id property.
+ *
+ * This is an appearance property and thus only applies if
+ * #GtkActivatable:use-action-appearance is %TRUE.
+ *
+ * Deprecated: 3.10
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_LABEL,
+ g_param_spec_string ("label",
+ P_("Label"),
+ P_("The label used for menu items and buttons "
+ "that activate this action."),
+ NULL,
+ GTK_PARAM_READWRITE));
+
+ /**
+ * GtkAction:short-label:
+ *
+ * A shorter label that may be used on toolbar buttons.
+ *
+ * This is an appearance property and thus only applies if
+ * #GtkActivatable:use-action-appearance is %TRUE.
+ *
+ * Deprecated: 3.10
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_SHORT_LABEL,
+ g_param_spec_string ("short-label",
+ P_("Short label"),
+ P_("A shorter label that may be used on toolbar buttons."),
+ NULL,
+ GTK_PARAM_READWRITE));
+
+
+ /**
+ * GtkAction:tooltip:
+ *
+ * A tooltip for this action.
+ *
+ * Deprecated: 3.10
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_TOOLTIP,
+ g_param_spec_string ("tooltip",
+ P_("Tooltip"),
+ P_("A tooltip for this action."),
+ NULL,
+ GTK_PARAM_READWRITE));
+
+ /**
+ * GtkAction:stock-id:
+ *
+ * The stock icon displayed in widgets representing this action.
+ *
+ * This is an appearance property and thus only applies if
+ * #GtkActivatable:use-action-appearance is %TRUE.
+ *
+ * Deprecated: 3.10
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_STOCK_ID,
+ g_param_spec_string ("stock-id",
+ P_("Stock Icon"),
+ P_("The stock icon displayed in widgets representing "
+ "this action."),
+ NULL,
+ GTK_PARAM_READWRITE));
+ /**
+ * GtkAction:gicon:
+ *
+ * The #GIcon displayed in the #GtkAction.
+ *
+ * Note that the stock icon is preferred, if the #GtkAction:stock-id
+ * property holds the id of an existing stock icon.
+ *
+ * This is an appearance property and thus only applies if
+ * #GtkActivatable:use-action-appearance is %TRUE.
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_GICON,
+ g_param_spec_object ("gicon",
+ P_("GIcon"),
+ P_("The GIcon being displayed"),
+ G_TYPE_ICON,
+ GTK_PARAM_READWRITE));
+ /**
+ * GtkAction:icon-name:
+ *
+ * The name of the icon from the icon theme.
+ *
+ * Note that the stock icon is preferred, if the #GtkAction:stock-id
+ * property holds the id of an existing stock icon, and the #GIcon is
+ * preferred if the #GtkAction:gicon property is set.
+ *
+ * This is an appearance property and thus only applies if
+ * #GtkActivatable:use-action-appearance is %TRUE.
+ *
+ * Since: 2.10
+ *
+ * Deprecated: 3.10
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_ICON_NAME,
+ g_param_spec_string ("icon-name",
+ P_("Icon Name"),
+ P_("The name of the icon from the icon theme"),
+ NULL,
+ GTK_PARAM_READWRITE));
+
+ /**
+ * GtkAction:visible-horizontal:
+ *
+ * Whether the toolbar item is visible when the toolbar is in a horizontal orientation.
+ *
+ * Deprecated: 3.10
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_VISIBLE_HORIZONTAL,
+ g_param_spec_boolean ("visible-horizontal",
+ P_("Visible when horizontal"),
+ P_("Whether the toolbar item is visible when the toolbar "
+ "is in a horizontal orientation."),
+ TRUE,
+ GTK_PARAM_READWRITE));
+ /**
+ * GtkAction:visible-overflown:
+ *
+ * When %TRUE, toolitem proxies for this action are represented in the
+ * toolbar overflow menu.
+ *
+ * Since: 2.6
+ *
+ * Deprecated: 3.10
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_VISIBLE_OVERFLOWN,
+ g_param_spec_boolean ("visible-overflown",
+ P_("Visible when overflown"),
+ P_("When TRUE, toolitem proxies for this action "
+ "are represented in the toolbar overflow menu."),
+ TRUE,
+ GTK_PARAM_READWRITE));
+
+ /**
+ * GtkAction:visible-vertical:
+ *
+ * Whether the toolbar item is visible when the toolbar is in a vertical orientation.
+ *
+ * Deprecated: 3.10
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_VISIBLE_VERTICAL,
+ g_param_spec_boolean ("visible-vertical",
+ P_("Visible when vertical"),
+ P_("Whether the toolbar item is visible when the toolbar "
+ "is in a vertical orientation."),
+ TRUE,
+ GTK_PARAM_READWRITE));
+ /**
+ * GtkAction:is-important:
+ *
+ * Whether the action is considered important. When TRUE, toolitem
+ * proxies for this action show text in GTK_TOOLBAR_BOTH_HORIZ mode.
+ *
+ * Deprecated: 3.10
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_IS_IMPORTANT,
+ g_param_spec_boolean ("is-important",
+ P_("Is important"),
+ P_("Whether the action is considered important. "
+ "When TRUE, toolitem proxies for this action "
+ "show text in GTK_TOOLBAR_BOTH_HORIZ mode."),
+ FALSE,
+ GTK_PARAM_READWRITE));
+ /**
+ * GtkAction:hide-if-empty:
+ *
+ * When TRUE, empty menu proxies for this action are hidden.
+ *
+ * Deprecated: 3.10
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_HIDE_IF_EMPTY,
+ g_param_spec_boolean ("hide-if-empty",
+ P_("Hide if empty"),
+ P_("When TRUE, empty menu proxies for this action are hidden."),
+ TRUE,
+ GTK_PARAM_READWRITE));
+ /**
+ * GtkAction:sensitive:
+ *
+ * Whether the action is enabled.
+ *
+ * Deprecated: 3.10
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_SENSITIVE,
+ g_param_spec_boolean ("sensitive",
+ P_("Sensitive"),
+ P_("Whether the action is enabled."),
+ TRUE,
+ GTK_PARAM_READWRITE));
+ /**
+ * GtkAction:visible:
+ *
+ * Whether the action is visible.
+ *
+ * Deprecated: 3.10
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_VISIBLE,
+ g_param_spec_boolean ("visible",
+ P_("Visible"),
+ P_("Whether the action is visible."),
+ TRUE,
+ GTK_PARAM_READWRITE));
+ /**
+ * GtkAction:action-group:
+ *
+ * The GtkActionGroup this GtkAction is associated with, or NULL
+ * (for internal use).
+ *
+ * Deprecated: 3.10
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_ACTION_GROUP,
+ g_param_spec_object ("action-group",
+ P_("Action Group"),
+ P_("The GtkActionGroup this GtkAction is associated with, or NULL (for internal use)."),
+ GTK_TYPE_ACTION_GROUP,
+ GTK_PARAM_READWRITE));
+
+ /**
+ * GtkAction:always-show-image:
+ *
+ * If %TRUE, the action's menu item proxies will always show their image, if available.
+ *
+ * Use this property if the menu item would be useless or hard to use
+ * without their image.
+ *
+ * Since: 2.20
+ *
+ * Deprecated: 3.10
+ **/
+ g_object_class_install_property (gobject_class,
+ PROP_ALWAYS_SHOW_IMAGE,
+ g_param_spec_boolean ("always-show-image",
+ P_("Always show image"),
+ P_("Whether the image will always be shown"),
+ FALSE,
+ GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ /**
+ * GtkAction::activate:
+ * @action: the #GtkAction
+ *
+ * The "activate" signal is emitted when the action is activated.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+ action_signals[ACTIVATE] =
+ g_signal_new (I_("activate"),
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
+ G_STRUCT_OFFSET (GtkActionClass, activate), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+}
+
+
+static void
+gtk_action_init (GtkAction *action)
+{
+ action->private_data = gtk_action_get_instance_private (action);
+
+ action->private_data->name = NULL;
+ action->private_data->label = NULL;
+ action->private_data->short_label = NULL;
+ action->private_data->tooltip = NULL;
+ action->private_data->stock_id = NULL;
+ action->private_data->icon_name = NULL;
+ action->private_data->visible_horizontal = TRUE;
+ action->private_data->visible_vertical = TRUE;
+ action->private_data->visible_overflown = TRUE;
+ action->private_data->is_important = FALSE;
+ action->private_data->hide_if_empty = TRUE;
+ action->private_data->always_show_image = FALSE;
+ action->private_data->activate_blocked = FALSE;
+
+ action->private_data->sensitive = TRUE;
+ action->private_data->visible = TRUE;
+
+ action->private_data->label_set = FALSE;
+ action->private_data->short_label_set = FALSE;
+
+ action->private_data->accel_count = 0;
+ action->private_data->accel_group = NULL;
+ action->private_data->accel_quark = 0;
+ action->private_data->accel_closure =
+ g_closure_new_object (sizeof (GClosure), G_OBJECT (action));
+ g_closure_set_marshal (action->private_data->accel_closure,
+ closure_accel_activate);
+ g_closure_ref (action->private_data->accel_closure);
+ g_closure_sink (action->private_data->accel_closure);
+
+ action->private_data->action_group = NULL;
+
+ action->private_data->proxies = NULL;
+ action->private_data->gicon = NULL;
+}
+
+static void
+gtk_action_buildable_init (GtkBuildableIface *iface)
+{
+ iface->set_name = gtk_action_buildable_set_name;
+ iface->get_name = gtk_action_buildable_get_name;
+}
+
+static void
+gtk_action_buildable_set_name (GtkBuildable *buildable,
+ const gchar *name)
+{
+ GtkAction *action = GTK_ACTION (buildable);
+
+ action->private_data->name = g_intern_string (name);
+}
+
+static const gchar *
+gtk_action_buildable_get_name (GtkBuildable *buildable)
+{
+ GtkAction *action = GTK_ACTION (buildable);
+
+ return action->private_data->name;
+}
+
+/**
+ * gtk_action_new:
+ * @name: A unique name for the action
+ * @label: (allow-none): the label displayed in menu items and on buttons,
+ * or %NULL
+ * @tooltip: (allow-none): a tooltip for the action, or %NULL
+ * @stock_id: (allow-none): the stock icon to display in widgets representing
+ * the action, or %NULL
+ *
+ * Creates a new #GtkAction object. To add the action to a
+ * #GtkActionGroup and set the accelerator for the action,
+ * call gtk_action_group_add_action_with_accel().
+ * See <xref linkend="XML-UI"/> for information on allowed action
+ * names.
+ *
+ * Return value: a new #GtkAction
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+GtkAction *
+gtk_action_new (const gchar *name,
+ const gchar *label,
+ const gchar *tooltip,
+ const gchar *stock_id)
+{
+ g_return_val_if_fail (name != NULL, NULL);
+
+ return g_object_new (GTK_TYPE_ACTION,
+ "name", name,
+ "label", label,
+ "tooltip", tooltip,
+ "stock-id", stock_id,
+ NULL);
+}
+
+static void
+gtk_action_finalize (GObject *object)
+{
+ GtkAction *action;
+ action = GTK_ACTION (object);
+
+ g_free (action->private_data->label);
+ g_free (action->private_data->short_label);
+ g_free (action->private_data->tooltip);
+ g_free (action->private_data->stock_id);
+ g_free (action->private_data->icon_name);
+
+ if (action->private_data->gicon)
+ g_object_unref (action->private_data->gicon);
+
+ g_closure_unref (action->private_data->accel_closure);
+ if (action->private_data->accel_group)
+ g_object_unref (action->private_data->accel_group);
+
+ G_OBJECT_CLASS (gtk_action_parent_class)->finalize (object);
+}
+
+static void
+gtk_action_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GtkAction *action;
+
+ action = GTK_ACTION (object);
+
+ switch (prop_id)
+ {
+ case PROP_NAME:
+ action->private_data->name = g_intern_string (g_value_get_string (value));
+ break;
+ case PROP_LABEL:
+ gtk_action_set_label (action, g_value_get_string (value));
+ break;
+ case PROP_SHORT_LABEL:
+ gtk_action_set_short_label (action, g_value_get_string (value));
+ break;
+ case PROP_TOOLTIP:
+ gtk_action_set_tooltip (action, g_value_get_string (value));
+ break;
+ case PROP_STOCK_ID:
+ gtk_action_set_stock_id (action, g_value_get_string (value));
+ break;
+ case PROP_GICON:
+ gtk_action_set_gicon (action, g_value_get_object (value));
+ break;
+ case PROP_ICON_NAME:
+ gtk_action_set_icon_name (action, g_value_get_string (value));
+ break;
+ case PROP_VISIBLE_HORIZONTAL:
+ gtk_action_set_visible_horizontal (action, g_value_get_boolean (value));
+ break;
+ case PROP_VISIBLE_VERTICAL:
+ gtk_action_set_visible_vertical (action, g_value_get_boolean (value));
+ break;
+ case PROP_VISIBLE_OVERFLOWN:
+ action->private_data->visible_overflown = g_value_get_boolean (value);
+ break;
+ case PROP_IS_IMPORTANT:
+ gtk_action_set_is_important (action, g_value_get_boolean (value));
+ break;
+ case PROP_HIDE_IF_EMPTY:
+ action->private_data->hide_if_empty = g_value_get_boolean (value);
+ break;
+ case PROP_SENSITIVE:
+ gtk_action_set_sensitive (action, g_value_get_boolean (value));
+ break;
+ case PROP_VISIBLE:
+ gtk_action_set_visible (action, g_value_get_boolean (value));
+ break;
+ case PROP_ACTION_GROUP:
+ gtk_action_set_action_group (action, g_value_get_object (value));
+ break;
+ case PROP_ALWAYS_SHOW_IMAGE:
+ gtk_action_set_always_show_image (action, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gtk_action_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GtkAction *action;
+
+ action = GTK_ACTION (object);
+
+ switch (prop_id)
+ {
+ case PROP_NAME:
+ g_value_set_static_string (value, action->private_data->name);
+ break;
+ case PROP_LABEL:
+ g_value_set_string (value, action->private_data->label);
+ break;
+ case PROP_SHORT_LABEL:
+ g_value_set_string (value, action->private_data->short_label);
+ break;
+ case PROP_TOOLTIP:
+ g_value_set_string (value, action->private_data->tooltip);
+ break;
+ case PROP_STOCK_ID:
+ g_value_set_string (value, action->private_data->stock_id);
+ break;
+ case PROP_ICON_NAME:
+ g_value_set_string (value, action->private_data->icon_name);
+ break;
+ case PROP_GICON:
+ g_value_set_object (value, action->private_data->gicon);
+ break;
+ case PROP_VISIBLE_HORIZONTAL:
+ g_value_set_boolean (value, action->private_data->visible_horizontal);
+ break;
+ case PROP_VISIBLE_VERTICAL:
+ g_value_set_boolean (value, action->private_data->visible_vertical);
+ break;
+ case PROP_VISIBLE_OVERFLOWN:
+ g_value_set_boolean (value, action->private_data->visible_overflown);
+ break;
+ case PROP_IS_IMPORTANT:
+ g_value_set_boolean (value, action->private_data->is_important);
+ break;
+ case PROP_HIDE_IF_EMPTY:
+ g_value_set_boolean (value, action->private_data->hide_if_empty);
+ break;
+ case PROP_SENSITIVE:
+ g_value_set_boolean (value, action->private_data->sensitive);
+ break;
+ case PROP_VISIBLE:
+ g_value_set_boolean (value, action->private_data->visible);
+ break;
+ case PROP_ACTION_GROUP:
+ g_value_set_object (value, action->private_data->action_group);
+ break;
+ case PROP_ALWAYS_SHOW_IMAGE:
+ g_value_set_boolean (value, action->private_data->always_show_image);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static GtkWidget *
+create_menu_item (GtkAction *action)
+{
+ GType menu_item_type;
+
+ menu_item_type = GTK_ACTION_GET_CLASS (action)->menu_item_type;
+
+ return g_object_new (menu_item_type, NULL);
+}
+
+static GtkWidget *
+create_tool_item (GtkAction *action)
+{
+ GType toolbar_item_type;
+
+ toolbar_item_type = GTK_ACTION_GET_CLASS (action)->toolbar_item_type;
+
+ return g_object_new (toolbar_item_type, NULL);
+}
+
+static void
+remove_proxy (GtkAction *action,
+ GtkWidget *proxy)
+{
+ g_object_unref (proxy);
+ action->private_data->proxies = g_slist_remove (action->private_data->proxies, proxy);
+}
+
+static void
+connect_proxy (GtkAction *action,
+ GtkWidget *proxy)
+{
+ action->private_data->proxies = g_slist_prepend (action->private_data->proxies, proxy);
+
+ g_object_ref_sink (proxy);
+
+ if (action->private_data->action_group)
+ _gtk_action_group_emit_connect_proxy (action->private_data->action_group, action, proxy);
+
+}
+
+static void
+disconnect_proxy (GtkAction *action,
+ GtkWidget *proxy)
+{
+ remove_proxy (action, proxy);
+
+ if (action->private_data->action_group)
+ _gtk_action_group_emit_disconnect_proxy (action->private_data->action_group, action, proxy);
+}
+
+/**
+ * _gtk_action_sync_menu_visible:
+ * @action: (allow-none): a #GtkAction, or %NULL to determine the action from @proxy
+ * @proxy: a proxy menu item
+ * @empty: whether the submenu attached to @proxy is empty
+ *
+ * Updates the visibility of @proxy from the visibility of @action
+ * according to the following rules:
+ * <itemizedlist>
+ * <listitem><para>if @action is invisible, @proxy is too
+ * </para></listitem>
+ * <listitem><para>if @empty is %TRUE, hide @proxy unless the "hide-if-empty"
+ * property of @action indicates otherwise
+ * </para></listitem>
+ * </itemizedlist>
+ *
+ * This function is used in the implementation of #GtkUIManager.
+ *
+ * Deprecated: 3.10
+ **/
+void
+_gtk_action_sync_menu_visible (GtkAction *action,
+ GtkWidget *proxy,
+ gboolean empty)
+{
+ gboolean visible = TRUE;
+ gboolean hide_if_empty = TRUE;
+
+ g_return_if_fail (GTK_IS_MENU_ITEM (proxy));
+ g_return_if_fail (action == NULL || GTK_IS_ACTION (action));
+
+ if (action == NULL)
+ action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy));
+
+ if (action)
+ {
+ /* a GtkMenu for a <popup/> doesn't have to have an action */
+ visible = gtk_action_is_visible (action);
+ hide_if_empty = action->private_data->hide_if_empty;
+ }
+
+ if (visible && !(empty && hide_if_empty))
+ gtk_widget_show (proxy);
+ else
+ gtk_widget_hide (proxy);
+}
+
+void
+_gtk_action_emit_activate (GtkAction *action)
+{
+ GtkActionGroup *group = action->private_data->action_group;
+
+ if (group != NULL)
+ {
+ g_object_ref (action);
+ g_object_ref (group);
+ _gtk_action_group_emit_pre_activate (group, action);
+ }
+
+ g_signal_emit (action, action_signals[ACTIVATE], 0);
+
+ if (group != NULL)
+ {
+ _gtk_action_group_emit_post_activate (group, action);
+ g_object_unref (group);
+ g_object_unref (action);
+ }
+}
+
+/**
+ * gtk_action_activate:
+ * @action: the action object
+ *
+ * Emits the "activate" signal on the specified action, if it isn't
+ * insensitive. This gets called by the proxy widgets when they get
+ * activated.
+ *
+ * It can also be used to manually activate an action.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_action_activate (GtkAction *action)
+{
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ if (action->private_data->activate_blocked)
+ return;
+
+ if (gtk_action_is_sensitive (action))
+ _gtk_action_emit_activate (action);
+}
+
+/**
+ * gtk_action_block_activate:
+ * @action: a #GtkAction
+ *
+ * Disable activation signals from the action
+ *
+ * This is needed when updating the state of your proxy
+ * #GtkActivatable widget could result in calling gtk_action_activate(),
+ * this is a convenience function to avoid recursing in those
+ * cases (updating toggle state for instance).
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_action_block_activate (GtkAction *action)
+{
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ action->private_data->activate_blocked = TRUE;
+}
+
+/**
+ * gtk_action_unblock_activate:
+ * @action: a #GtkAction
+ *
+ * Reenable activation signals from the action
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_action_unblock_activate (GtkAction *action)
+{
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ action->private_data->activate_blocked = FALSE;
+}
+
+/**
+ * gtk_action_create_icon:
+ * @action: the action object
+ * @icon_size: (type int): the size of the icon that should be created.
+ *
+ * This function is intended for use by action implementations to
+ * create icons displayed in the proxy widgets.
+ *
+ * Returns: (transfer none): a widget that displays the icon for this action.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+GtkWidget *
+gtk_action_create_icon (GtkAction *action, GtkIconSize icon_size)
+{
+ GtkWidget *widget = NULL;
+
+ g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+
+ if (action->private_data->stock_id &&
+ gtk_icon_factory_lookup_default (action->private_data->stock_id))
+ widget = gtk_image_new_from_stock (action->private_data->stock_id, icon_size);
+ else if (action->private_data->gicon)
+ widget = gtk_image_new_from_gicon (action->private_data->gicon, icon_size);
+ else if (action->private_data->icon_name)
+ widget = gtk_image_new_from_icon_name (action->private_data->icon_name, icon_size);
+
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+
+ return widget;
+}
+
+/**
+ * gtk_action_create_menu_item:
+ * @action: the action object
+ *
+ * Creates a menu item widget that proxies for the given action.
+ *
+ * Returns: (transfer none): a menu item connected to the action.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+GtkWidget *
+gtk_action_create_menu_item (GtkAction *action)
+{
+ GtkWidget *menu_item;
+
+ g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
+
+ menu_item = GTK_ACTION_GET_CLASS (action)->create_menu_item (action);
+
+ gtk_activatable_set_use_action_appearance (GTK_ACTIVATABLE (menu_item), TRUE);
+ gtk_activatable_set_related_action (GTK_ACTIVATABLE (menu_item), action);
+
+ return menu_item;
+}
+
+/**
+ * gtk_action_create_tool_item:
+ * @action: the action object
+ *
+ * Creates a toolbar item widget that proxies for the given action.
+ *
+ * Returns: (transfer none): a toolbar item connected to the action.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+GtkWidget *
+gtk_action_create_tool_item (GtkAction *action)
+{
+ GtkWidget *button;
+
+ g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
+
+ button = GTK_ACTION_GET_CLASS (action)->create_tool_item (action);
+
+ gtk_activatable_set_use_action_appearance (GTK_ACTIVATABLE (button), TRUE);
+ gtk_activatable_set_related_action (GTK_ACTIVATABLE (button), action);
+
+ return button;
+}
+
+void
+_gtk_action_add_to_proxy_list (GtkAction *action,
+ GtkWidget *proxy)
+{
+ g_return_if_fail (GTK_IS_ACTION (action));
+ g_return_if_fail (GTK_IS_WIDGET (proxy));
+
+ GTK_ACTION_GET_CLASS (action)->connect_proxy (action, proxy);
+}
+
+void
+_gtk_action_remove_from_proxy_list (GtkAction *action,
+ GtkWidget *proxy)
+{
+ g_return_if_fail (GTK_IS_ACTION (action));
+ g_return_if_fail (GTK_IS_WIDGET (proxy));
+
+ GTK_ACTION_GET_CLASS (action)->disconnect_proxy (action, proxy);
+}
+
+/**
+ * gtk_action_get_proxies:
+ * @action: the action object
+ *
+ * Returns the proxy widgets for an action.
+ * See also gtk_activatable_get_related_action().
+ *
+ * Return value: (element-type GtkWidget) (transfer none): a #GSList of proxy widgets. The list is owned by GTK+
+ * and must not be modified.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+GSList*
+gtk_action_get_proxies (GtkAction *action)
+{
+ g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
+
+ return action->private_data->proxies;
+}
+
+/**
+ * gtk_action_get_name:
+ * @action: the action object
+ *
+ * Returns the name of the action.
+ *
+ * Return value: the name of the action. The string belongs to GTK+ and should not
+ * be freed.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+const gchar *
+gtk_action_get_name (GtkAction *action)
+{
+ g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
+
+ return action->private_data->name;
+}
+
+/**
+ * gtk_action_is_sensitive:
+ * @action: the action object
+ *
+ * Returns whether the action is effectively sensitive.
+ *
+ * Return value: %TRUE if the action and its associated action group
+ * are both sensitive.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+gboolean
+gtk_action_is_sensitive (GtkAction *action)
+{
+ GtkActionPrivate *priv;
+ g_return_val_if_fail (GTK_IS_ACTION (action), FALSE);
+
+ priv = action->private_data;
+ return priv->sensitive &&
+ (priv->action_group == NULL ||
+ gtk_action_group_get_sensitive (priv->action_group));
+}
+
+/**
+ * gtk_action_get_sensitive:
+ * @action: the action object
+ *
+ * Returns whether the action itself is sensitive. Note that this doesn't
+ * necessarily mean effective sensitivity. See gtk_action_is_sensitive()
+ * for that.
+ *
+ * Return value: %TRUE if the action itself is sensitive.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+gboolean
+gtk_action_get_sensitive (GtkAction *action)
+{
+ g_return_val_if_fail (GTK_IS_ACTION (action), FALSE);
+
+ return action->private_data->sensitive;
+}
+
+/**
+ * gtk_action_set_sensitive:
+ * @action: the action object
+ * @sensitive: %TRUE to make the action sensitive
+ *
+ * Sets the ::sensitive property of the action to @sensitive. Note that
+ * this doesn't necessarily mean effective sensitivity. See
+ * gtk_action_is_sensitive()
+ * for that.
+ *
+ * Since: 2.6
+ *
+ * Deprecated: 3.10
+ **/
+void
+gtk_action_set_sensitive (GtkAction *action,
+ gboolean sensitive)
+{
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ sensitive = sensitive != FALSE;
+
+ if (action->private_data->sensitive != sensitive)
+ {
+ action->private_data->sensitive = sensitive;
+
+ g_object_notify (G_OBJECT (action), "sensitive");
+ }
+}
+
+/**
+ * gtk_action_is_visible:
+ * @action: the action object
+ *
+ * Returns whether the action is effectively visible.
+ *
+ * Return value: %TRUE if the action and its associated action group
+ * are both visible.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+gboolean
+gtk_action_is_visible (GtkAction *action)
+{
+ GtkActionPrivate *priv;
+ g_return_val_if_fail (GTK_IS_ACTION (action), FALSE);
+
+ priv = action->private_data;
+ return priv->visible &&
+ (priv->action_group == NULL ||
+ gtk_action_group_get_visible (priv->action_group));
+}
+
+/**
+ * gtk_action_get_visible:
+ * @action: the action object
+ *
+ * Returns whether the action itself is visible. Note that this doesn't
+ * necessarily mean effective visibility. See gtk_action_is_sensitive()
+ * for that.
+ *
+ * Return value: %TRUE if the action itself is visible.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+gboolean
+gtk_action_get_visible (GtkAction *action)
+{
+ g_return_val_if_fail (GTK_IS_ACTION (action), FALSE);
+
+ return action->private_data->visible;
+}
+
+/**
+ * gtk_action_set_visible:
+ * @action: the action object
+ * @visible: %TRUE to make the action visible
+ *
+ * Sets the ::visible property of the action to @visible. Note that
+ * this doesn't necessarily mean effective visibility. See
+ * gtk_action_is_visible()
+ * for that.
+ *
+ * Since: 2.6
+ *
+ * Deprecated: 3.10
+ **/
+void
+gtk_action_set_visible (GtkAction *action,
+ gboolean visible)
+{
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ visible = visible != FALSE;
+
+ if (action->private_data->visible != visible)
+ {
+ action->private_data->visible = visible;
+
+ g_object_notify (G_OBJECT (action), "visible");
+ }
+}
+/**
+ * gtk_action_set_is_important:
+ * @action: the action object
+ * @is_important: %TRUE to make the action important
+ *
+ * Sets whether the action is important, this attribute is used
+ * primarily by toolbar items to decide whether to show a label
+ * or not.
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_action_set_is_important (GtkAction *action,
+ gboolean is_important)
+{
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ is_important = is_important != FALSE;
+
+ if (action->private_data->is_important != is_important)
+ {
+ action->private_data->is_important = is_important;
+
+ g_object_notify (G_OBJECT (action), "is-important");
+ }
+}
+
+/**
+ * gtk_action_get_is_important:
+ * @action: a #GtkAction
+ *
+ * Checks whether @action is important or not
+ *
+ * Returns: whether @action is important
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ */
+gboolean
+gtk_action_get_is_important (GtkAction *action)
+{
+ g_return_val_if_fail (GTK_IS_ACTION (action), FALSE);
+
+ return action->private_data->is_important;
+}
+
+/**
+ * gtk_action_set_always_show_image:
+ * @action: a #GtkAction
+ * @always_show: %TRUE if menuitem proxies should always show their image
+ *
+ * Sets whether @action<!-- -->'s menu item proxies will always show
+ * their image, if available.
+ *
+ * Use this if the menu item would be useless or hard to use
+ * without their image.
+ *
+ * Since: 2.20
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_action_set_always_show_image (GtkAction *action,
+ gboolean always_show)
+{
+ GtkActionPrivate *priv;
+
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ priv = action->private_data;
+
+ always_show = always_show != FALSE;
+
+ if (priv->always_show_image != always_show)
+ {
+ priv->always_show_image = always_show;
+
+ g_object_notify (G_OBJECT (action), "always-show-image");
+ }
+}
+
+/**
+ * gtk_action_get_always_show_image:
+ * @action: a #GtkAction
+ *
+ * Returns whether @action<!-- -->'s menu item proxies will always
+ * show their image, if available.
+ *
+ * Returns: %TRUE if the menu item proxies will always show their image
+ *
+ * Since: 2.20
+ *
+ * Deprecated: 3.10
+ */
+gboolean
+gtk_action_get_always_show_image (GtkAction *action)
+{
+ g_return_val_if_fail (GTK_IS_ACTION (action), FALSE);
+
+ return action->private_data->always_show_image;
+}
+
+/**
+ * gtk_action_set_label:
+ * @action: a #GtkAction
+ * @label: the label text to set
+ *
+ * Sets the label of @action.
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_action_set_label (GtkAction *action,
+ const gchar *label)
+{
+ gchar *tmp;
+
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ tmp = action->private_data->label;
+ action->private_data->label = g_strdup (label);
+ g_free (tmp);
+ action->private_data->label_set = (action->private_data->label != NULL);
+ /* if label is unset, then use the label from the stock item */
+ if (!action->private_data->label_set && action->private_data->stock_id)
+ {
+ GtkStockItem stock_item;
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+
+ if (gtk_stock_lookup (action->private_data->stock_id, &stock_item))
+ action->private_data->label = g_strdup (stock_item.label);
+
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+ }
+
+ g_object_notify (G_OBJECT (action), "label");
+
+ /* if short_label is unset, set short_label=label */
+ if (!action->private_data->short_label_set)
+ {
+ gtk_action_set_short_label (action, action->private_data->label);
+ action->private_data->short_label_set = FALSE;
+ }
+}
+
+/**
+ * gtk_action_get_label:
+ * @action: a #GtkAction
+ *
+ * Gets the label text of @action.
+ *
+ * Returns: the label text
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ */
+const gchar *
+gtk_action_get_label (GtkAction *action)
+{
+ g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
+
+ return action->private_data->label;
+}
+
+/**
+ * gtk_action_set_short_label:
+ * @action: a #GtkAction
+ * @short_label: the label text to set
+ *
+ * Sets a shorter label text on @action.
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_action_set_short_label (GtkAction *action,
+ const gchar *short_label)
+{
+ gchar *tmp;
+
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ tmp = action->private_data->short_label;
+ action->private_data->short_label = g_strdup (short_label);
+ g_free (tmp);
+ action->private_data->short_label_set = (action->private_data->short_label != NULL);
+ /* if short_label is unset, then use the value of label */
+ if (!action->private_data->short_label_set)
+ action->private_data->short_label = g_strdup (action->private_data->label);
+
+ g_object_notify (G_OBJECT (action), "short-label");
+}
+
+/**
+ * gtk_action_get_short_label:
+ * @action: a #GtkAction
+ *
+ * Gets the short label text of @action.
+ *
+ * Returns: the short label text.
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ */
+const gchar *
+gtk_action_get_short_label (GtkAction *action)
+{
+ g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
+
+ return action->private_data->short_label;
+}
+
+/**
+ * gtk_action_set_visible_horizontal:
+ * @action: a #GtkAction
+ * @visible_horizontal: whether the action is visible horizontally
+ *
+ * Sets whether @action is visible when horizontal
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_action_set_visible_horizontal (GtkAction *action,
+ gboolean visible_horizontal)
+{
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ visible_horizontal = visible_horizontal != FALSE;
+
+ if (action->private_data->visible_horizontal != visible_horizontal)
+ {
+ action->private_data->visible_horizontal = visible_horizontal;
+
+ g_object_notify (G_OBJECT (action), "visible-horizontal");
+ }
+}
+
+/**
+ * gtk_action_get_visible_horizontal:
+ * @action: a #GtkAction
+ *
+ * Checks whether @action is visible when horizontal
+ *
+ * Returns: whether @action is visible when horizontal
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ */
+gboolean
+gtk_action_get_visible_horizontal (GtkAction *action)
+{
+ g_return_val_if_fail (GTK_IS_ACTION (action), FALSE);
+
+ return action->private_data->visible_horizontal;
+}
+
+/**
+ * gtk_action_set_visible_vertical:
+ * @action: a #GtkAction
+ * @visible_vertical: whether the action is visible vertically
+ *
+ * Sets whether @action is visible when vertical
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_action_set_visible_vertical (GtkAction *action,
+ gboolean visible_vertical)
+{
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ visible_vertical = visible_vertical != FALSE;
+
+ if (action->private_data->visible_vertical != visible_vertical)
+ {
+ action->private_data->visible_vertical = visible_vertical;
+
+ g_object_notify (G_OBJECT (action), "visible-vertical");
+ }
+}
+
+/**
+ * gtk_action_get_visible_vertical:
+ * @action: a #GtkAction
+ *
+ * Checks whether @action is visible when horizontal
+ *
+ * Returns: whether @action is visible when horizontal
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ */
+gboolean
+gtk_action_get_visible_vertical (GtkAction *action)
+{
+ g_return_val_if_fail (GTK_IS_ACTION (action), FALSE);
+
+ return action->private_data->visible_vertical;
+}
+
+/**
+ * gtk_action_set_tooltip:
+ * @action: a #GtkAction
+ * @tooltip: the tooltip text
+ *
+ * Sets the tooltip text on @action
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_action_set_tooltip (GtkAction *action,
+ const gchar *tooltip)
+{
+ gchar *tmp;
+
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ tmp = action->private_data->tooltip;
+ action->private_data->tooltip = g_strdup (tooltip);
+ g_free (tmp);
+
+ g_object_notify (G_OBJECT (action), "tooltip");
+}
+
+/**
+ * gtk_action_get_tooltip:
+ * @action: a #GtkAction
+ *
+ * Gets the tooltip text of @action.
+ *
+ * Returns: the tooltip text
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ */
+const gchar *
+gtk_action_get_tooltip (GtkAction *action)
+{
+ g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
+
+ return action->private_data->tooltip;
+}
+
+/**
+ * gtk_action_set_stock_id:
+ * @action: a #GtkAction
+ * @stock_id: the stock id
+ *
+ * Sets the stock id on @action
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_action_set_stock_id (GtkAction *action,
+ const gchar *stock_id)
+{
+ gchar *tmp;
+
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ tmp = action->private_data->stock_id;
+ action->private_data->stock_id = g_strdup (stock_id);
+ g_free (tmp);
+
+ g_object_notify (G_OBJECT (action), "stock-id");
+
+ /* update label and short_label if appropriate */
+ if (!action->private_data->label_set)
+ {
+ GtkStockItem stock_item;
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+
+ if (action->private_data->stock_id &&
+ gtk_stock_lookup (action->private_data->stock_id, &stock_item))
+ gtk_action_set_label (action, stock_item.label);
+ else
+ gtk_action_set_label (action, NULL);
+
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+
+ action->private_data->label_set = FALSE;
+ }
+}
+
+/**
+ * gtk_action_get_stock_id:
+ * @action: a #GtkAction
+ *
+ * Gets the stock id of @action.
+ *
+ * Returns: the stock id
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ */
+const gchar *
+gtk_action_get_stock_id (GtkAction *action)
+{
+ g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
+
+ return action->private_data->stock_id;
+}
+
+/**
+ * gtk_action_set_icon_name:
+ * @action: a #GtkAction
+ * @icon_name: the icon name to set
+ *
+ * Sets the icon name on @action
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_action_set_icon_name (GtkAction *action,
+ const gchar *icon_name)
+{
+ gchar *tmp;
+
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ tmp = action->private_data->icon_name;
+ action->private_data->icon_name = g_strdup (icon_name);
+ g_free (tmp);
+
+ g_object_notify (G_OBJECT (action), "icon-name");
+}
+
+/**
+ * gtk_action_get_icon_name:
+ * @action: a #GtkAction
+ *
+ * Gets the icon name of @action.
+ *
+ * Returns: the icon name
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ */
+const gchar *
+gtk_action_get_icon_name (GtkAction *action)
+{
+ g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
+
+ return action->private_data->icon_name;
+}
+
+/**
+ * gtk_action_set_gicon:
+ * @action: a #GtkAction
+ * @icon: the #GIcon to set
+ *
+ * Sets the icon of @action.
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_action_set_gicon (GtkAction *action,
+ GIcon *icon)
+{
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ if (action->private_data->gicon)
+ g_object_unref (action->private_data->gicon);
+
+ action->private_data->gicon = icon;
+
+ if (action->private_data->gicon)
+ g_object_ref (action->private_data->gicon);
+
+ g_object_notify (G_OBJECT (action), "gicon");
+}
+
+/**
+ * gtk_action_get_gicon:
+ * @action: a #GtkAction
+ *
+ * Gets the gicon of @action.
+ *
+ * Returns: (transfer none): The action's #GIcon if one is set.
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ */
+GIcon *
+gtk_action_get_gicon (GtkAction *action)
+{
+ g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
+
+ return action->private_data->gicon;
+}
+
+static void
+closure_accel_activate (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ if (gtk_action_is_sensitive (GTK_ACTION (closure->data)))
+ {
+ _gtk_action_emit_activate (GTK_ACTION (closure->data));
+
+ /* we handled the accelerator */
+ g_value_set_boolean (return_value, TRUE);
+ }
+}
+
+static void
+gtk_action_set_action_group (GtkAction *action,
+ GtkActionGroup *action_group)
+{
+ if (action->private_data->action_group == NULL)
+ g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
+ else
+ g_return_if_fail (action_group == NULL);
+
+ action->private_data->action_group = action_group;
+}
+
+/**
+ * gtk_action_set_accel_path:
+ * @action: the action object
+ * @accel_path: the accelerator path
+ *
+ * Sets the accel path for this action. All proxy widgets associated
+ * with the action will have this accel path, so that their
+ * accelerators are consistent.
+ *
+ * Note that @accel_path string will be stored in a #GQuark. Therefore, if you
+ * pass a static string, you can save some memory by interning it first with
+ * g_intern_static_string().
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_action_set_accel_path (GtkAction *action,
+ const gchar *accel_path)
+{
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ action->private_data->accel_quark = g_quark_from_string (accel_path);
+}
+
+/**
+ * gtk_action_get_accel_path:
+ * @action: the action object
+ *
+ * Returns the accel path for this action.
+ *
+ * Since: 2.6
+ *
+ * Returns: the accel path for this action, or %NULL
+ * if none is set. The returned string is owned by GTK+
+ * and must not be freed or modified.
+ *
+ * Deprecated: 3.10
+ */
+const gchar *
+gtk_action_get_accel_path (GtkAction *action)
+{
+ g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
+
+ if (action->private_data->accel_quark)
+ return g_quark_to_string (action->private_data->accel_quark);
+ else
+ return NULL;
+}
+
+/**
+ * gtk_action_get_accel_closure:
+ * @action: the action object
+ *
+ * Returns the accel closure for this action.
+ *
+ * Since: 2.8
+ *
+ * Returns: (transfer none): the accel closure for this action. The
+ * returned closure is owned by GTK+ and must not be unreffed
+ * or modified.
+ *
+ * Deprecated: 3.10
+ */
+GClosure *
+gtk_action_get_accel_closure (GtkAction *action)
+{
+ g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
+
+ return action->private_data->accel_closure;
+}
+
+
+/**
+ * gtk_action_set_accel_group:
+ * @action: the action object
+ * @accel_group: (allow-none): a #GtkAccelGroup or %NULL
+ *
+ * Sets the #GtkAccelGroup in which the accelerator for this action
+ * will be installed.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+void
+gtk_action_set_accel_group (GtkAction *action,
+ GtkAccelGroup *accel_group)
+{
+ g_return_if_fail (GTK_IS_ACTION (action));
+ g_return_if_fail (accel_group == NULL || GTK_IS_ACCEL_GROUP (accel_group));
+
+ if (accel_group)
+ g_object_ref (accel_group);
+ if (action->private_data->accel_group)
+ g_object_unref (action->private_data->accel_group);
+
+ action->private_data->accel_group = accel_group;
+}
+
+/**
+ * gtk_action_connect_accelerator:
+ * @action: a #GtkAction
+ *
+ * Installs the accelerator for @action if @action has an
+ * accel path and group. See gtk_action_set_accel_path() and
+ * gtk_action_set_accel_group()
+ *
+ * Since multiple proxies may independently trigger the installation
+ * of the accelerator, the @action counts the number of times this
+ * function has been called and doesn't remove the accelerator until
+ * gtk_action_disconnect_accelerator() has been called as many times.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+void
+gtk_action_connect_accelerator (GtkAction *action)
+{
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ if (!action->private_data->accel_quark ||
+ !action->private_data->accel_group)
+ return;
+
+ if (action->private_data->accel_count == 0)
+ {
+ const gchar *accel_path =
+ g_quark_to_string (action->private_data->accel_quark);
+
+ gtk_accel_group_connect_by_path (action->private_data->accel_group,
+ accel_path,
+ action->private_data->accel_closure);
+ }
+
+ action->private_data->accel_count++;
+}
+
+/**
+ * gtk_action_disconnect_accelerator:
+ * @action: a #GtkAction
+ *
+ * Undoes the effect of one call to gtk_action_connect_accelerator().
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+void
+gtk_action_disconnect_accelerator (GtkAction *action)
+{
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ if (!action->private_data->accel_quark ||
+ !action->private_data->accel_group)
+ return;
+
+ action->private_data->accel_count--;
+
+ if (action->private_data->accel_count == 0)
+ gtk_accel_group_disconnect (action->private_data->accel_group,
+ action->private_data->accel_closure);
+}
+
+/**
+ * gtk_action_create_menu:
+ * @action: a #GtkAction
+ *
+ * If @action provides a #GtkMenu widget as a submenu for the menu
+ * item or the toolbar item it creates, this function returns an
+ * instance of that menu.
+ *
+ * Return value: (transfer none): the menu item provided by the
+ * action, or %NULL.
+ *
+ * Since: 2.12
+ *
+ * Deprecated: 3.10
+ */
+GtkWidget *
+gtk_action_create_menu (GtkAction *action)
+{
+ g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
+
+ if (GTK_ACTION_GET_CLASS (action)->create_menu)
+ return GTK_ACTION_GET_CLASS (action)->create_menu (action);
+
+ return NULL;
+}
--- /dev/null
+/*
+ * GTK - The GIMP Toolkit
+ * Copyright (C) 1998, 1999 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Author: James Henstridge <james@daa.com.au>
+ *
+ * Modified by the GTK+ Team and others 2003. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __GTK_ACTION_H__
+#define __GTK_ACTION_H__
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#include <gtk/gtkwidget.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_ACTION (gtk_action_get_type ())
+#define GTK_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ACTION, GtkAction))
+#define GTK_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ACTION, GtkActionClass))
+#define GTK_IS_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ACTION))
+#define GTK_IS_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ACTION))
+#define GTK_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_ACTION, GtkActionClass))
+
+typedef struct _GtkAction GtkAction;
+typedef struct _GtkActionClass GtkActionClass;
+typedef struct _GtkActionPrivate GtkActionPrivate;
+
+struct _GtkAction
+{
+ GObject object;
+
+ /*< private >*/
+ GtkActionPrivate *private_data;
+};
+
+struct _GtkActionClass
+{
+ GObjectClass parent_class;
+
+ /* activation signal */
+ void (* activate) (GtkAction *action);
+
+ GType menu_item_type;
+ GType toolbar_item_type;
+
+ /* widget creation routines (not signals) */
+ GtkWidget *(* create_menu_item) (GtkAction *action);
+ GtkWidget *(* create_tool_item) (GtkAction *action);
+ void (* connect_proxy) (GtkAction *action,
+ GtkWidget *proxy);
+ void (* disconnect_proxy) (GtkAction *action,
+ GtkWidget *proxy);
+
+ GtkWidget *(* create_menu) (GtkAction *action);
+
+ /* Padding for future expansion */
+ void (*_gtk_reserved1) (void);
+ void (*_gtk_reserved2) (void);
+ void (*_gtk_reserved3) (void);
+ void (*_gtk_reserved4) (void);
+};
+
+GDK_DEPRECATED_IN_3_10
+GType gtk_action_get_type (void) G_GNUC_CONST;
+GDK_DEPRECATED_IN_3_10
+GtkAction *gtk_action_new (const gchar *name,
+ const gchar *label,
+ const gchar *tooltip,
+ const gchar *stock_id);
+GDK_DEPRECATED_IN_3_10
+const gchar* gtk_action_get_name (GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+gboolean gtk_action_is_sensitive (GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+gboolean gtk_action_get_sensitive (GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_set_sensitive (GtkAction *action,
+ gboolean sensitive);
+GDK_DEPRECATED_IN_3_10
+gboolean gtk_action_is_visible (GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+gboolean gtk_action_get_visible (GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_set_visible (GtkAction *action,
+ gboolean visible);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_activate (GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+GtkWidget * gtk_action_create_icon (GtkAction *action,
+ GtkIconSize icon_size);
+GDK_DEPRECATED_IN_3_10
+GtkWidget * gtk_action_create_menu_item (GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+GtkWidget * gtk_action_create_tool_item (GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+GtkWidget * gtk_action_create_menu (GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+GSList * gtk_action_get_proxies (GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_connect_accelerator (GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_disconnect_accelerator (GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+const gchar *gtk_action_get_accel_path (GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+GClosure *gtk_action_get_accel_closure (GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_block_activate (GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_unblock_activate (GtkAction *action);
+
+void _gtk_action_add_to_proxy_list (GtkAction *action,
+ GtkWidget *proxy);
+void _gtk_action_remove_from_proxy_list(GtkAction *action,
+ GtkWidget *proxy);
+
+/* protected ... for use by child actions */
+void _gtk_action_emit_activate (GtkAction *action);
+
+/* protected ... for use by action groups */
+GDK_DEPRECATED_IN_3_10
+void gtk_action_set_accel_path (GtkAction *action,
+ const gchar *accel_path);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_set_accel_group (GtkAction *action,
+ GtkAccelGroup *accel_group);
+void _gtk_action_sync_menu_visible (GtkAction *action,
+ GtkWidget *proxy,
+ gboolean empty);
+
+GDK_DEPRECATED_IN_3_10
+void gtk_action_set_label (GtkAction *action,
+ const gchar *label);
+GDK_DEPRECATED_IN_3_10
+const gchar * gtk_action_get_label (GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_set_short_label (GtkAction *action,
+ const gchar *short_label);
+GDK_DEPRECATED_IN_3_10
+const gchar * gtk_action_get_short_label (GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_set_tooltip (GtkAction *action,
+ const gchar *tooltip);
+GDK_DEPRECATED_IN_3_10
+const gchar * gtk_action_get_tooltip (GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_set_stock_id (GtkAction *action,
+ const gchar *stock_id);
+GDK_DEPRECATED_IN_3_10
+const gchar * gtk_action_get_stock_id (GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_set_gicon (GtkAction *action,
+ GIcon *icon);
+GDK_DEPRECATED_IN_3_10
+GIcon *gtk_action_get_gicon (GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_set_icon_name (GtkAction *action,
+ const gchar *icon_name);
+GDK_DEPRECATED_IN_3_10
+const gchar * gtk_action_get_icon_name (GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_set_visible_horizontal (GtkAction *action,
+ gboolean visible_horizontal);
+GDK_DEPRECATED_IN_3_10
+gboolean gtk_action_get_visible_horizontal (GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_set_visible_vertical (GtkAction *action,
+ gboolean visible_vertical);
+GDK_DEPRECATED_IN_3_10
+gboolean gtk_action_get_visible_vertical (GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_set_is_important (GtkAction *action,
+ gboolean is_important);
+GDK_DEPRECATED_IN_3_10
+gboolean gtk_action_get_is_important (GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_set_always_show_image (GtkAction *action,
+ gboolean always_show);
+GDK_DEPRECATED_IN_3_10
+gboolean gtk_action_get_always_show_image (GtkAction *action);
+
+
+G_END_DECLS
+
+#endif /* __GTK_ACTION_H__ */
--- /dev/null
+/*
+ * GTK - The GIMP Toolkit
+ * Copyright (C) 1998, 1999 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Author: James Henstridge <james@daa.com.au>
+ *
+ * Modified by the GTK+ Team and others 2003. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+/**
+ * SECTION:gtkactiongroup
+ * @Short_description: A group of actions
+ * @Title: GtkActionGroup
+ *
+ * Actions are organised into groups. An action group is essentially a
+ * map from names to #GtkAction objects.
+ *
+ * All actions that would make sense to use in a particular context
+ * should be in a single group. Multiple action groups may be used for a
+ * particular user interface. In fact, it is expected that most nontrivial
+ * applications will make use of multiple groups. For example, in an
+ * application that can edit multiple documents, one group holding global
+ * actions (e.g. quit, about, new), and one group per document holding
+ * actions that act on that document (eg. save, cut/copy/paste, etc). Each
+ * window's menus would be constructed from a combination of two action
+ * groups.
+ * </para>
+ * <para id="Action-Accel">
+ * Accelerators are handled by the GTK+ accelerator map. All actions are
+ * assigned an accelerator path (which normally has the form
+ * <literal><Actions>/group-name/action-name</literal>)
+ * and a shortcut is associated with this accelerator path. All menuitems
+ * and toolitems take on this accelerator path. The GTK+ accelerator map
+ * code makes sure that the correct shortcut is displayed next to the menu
+ * item.
+ *
+ * <refsect2 id="GtkActionGroup-BUILDER-UI">
+ * <title>GtkActionGroup as GtkBuildable</title>
+ * <para>
+ * The #GtkActionGroup implementation of the #GtkBuildable interface accepts
+ * #GtkAction objects as <child> elements in UI definitions.
+ *
+ * Note that it is probably more common to define actions and action groups
+ * in the code, since they are directly related to what the code can do.
+ *
+ * The GtkActionGroup implementation of the GtkBuildable interface supports
+ * a custom <accelerator> element, which has attributes named key and
+ * modifiers and allows to specify accelerators. This is similar to the
+ * <accelerator> element of #GtkWidget, the main difference is that
+ * it doesn't allow you to specify a signal.
+ * </para>
+ * <example>
+ * <title>A #GtkDialog UI definition fragment.</title>
+ * <programlisting><![CDATA[
+ * <object class="GtkActionGroup" id="actiongroup">
+ * <child>
+ * <object class="GtkAction" id="About">
+ * <property name="name">About</property>
+ * <property name="stock_id">gtk-about</property>
+ * <signal handler="about_activate" name="activate"/>
+ * </object>
+ * <accelerator key="F1" modifiers="GDK_CONTROL_MASK | GDK_SHIFT_MASK"/>
+ * </child>
+ * </object>
+ * ]]></programlisting>
+ * </example>
+ * </refsect2>
+ */
+
+#include "config.h"
+#include <string.h>
+
+#define GDK_DISABLE_DEPRECATION_WARNINGS
+
+#include "gtkactiongroup.h"
+#include "gtkbuildable.h"
+#include "gtkiconfactory.h"
+#include "gtkicontheme.h"
+#include "gtkstock.h"
+#include "gtktoggleaction.h"
+#include "gtkradioaction.h"
+#include "gtkaccelmap.h"
+#include "gtkmarshalers.h"
+#include "gtkbuilderprivate.h"
+#include "gtkprivate.h"
+#include "gtkintl.h"
+
+
+struct _GtkActionGroupPrivate
+{
+ gchar *name;
+ gboolean sensitive;
+ gboolean visible;
+ GHashTable *actions;
+ GtkAccelGroup *accel_group;
+
+ GtkTranslateFunc translate_func;
+ gpointer translate_data;
+ GDestroyNotify translate_notify;
+};
+
+enum
+{
+ CONNECT_PROXY,
+ DISCONNECT_PROXY,
+ PRE_ACTIVATE,
+ POST_ACTIVATE,
+ LAST_SIGNAL
+};
+
+enum
+{
+ PROP_0,
+ PROP_NAME,
+ PROP_SENSITIVE,
+ PROP_VISIBLE,
+ PROP_ACCEL_GROUP
+};
+
+static void gtk_action_group_init (GtkActionGroup *self);
+static void gtk_action_group_class_init (GtkActionGroupClass *class);
+static void gtk_action_group_finalize (GObject *object);
+static void gtk_action_group_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gtk_action_group_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static GtkAction *gtk_action_group_real_get_action (GtkActionGroup *self,
+ const gchar *name);
+
+/* GtkBuildable */
+static void gtk_action_group_buildable_init (GtkBuildableIface *iface);
+static void gtk_action_group_buildable_add_child (GtkBuildable *buildable,
+ GtkBuilder *builder,
+ GObject *child,
+ const gchar *type);
+static void gtk_action_group_buildable_set_name (GtkBuildable *buildable,
+ const gchar *name);
+static const gchar* gtk_action_group_buildable_get_name (GtkBuildable *buildable);
+static gboolean gtk_action_group_buildable_custom_tag_start (GtkBuildable *buildable,
+ GtkBuilder *builder,
+ GObject *child,
+ const gchar *tagname,
+ GMarkupParser *parser,
+ gpointer *data);
+static void gtk_action_group_buildable_custom_tag_end (GtkBuildable *buildable,
+ GtkBuilder *builder,
+ GObject *child,
+ const gchar *tagname,
+ gpointer *user_data);
+
+static guint action_group_signals[LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE_WITH_CODE (GtkActionGroup, gtk_action_group, G_TYPE_OBJECT,
+ G_ADD_PRIVATE (GtkActionGroup)
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
+ gtk_action_group_buildable_init))
+
+static void
+gtk_action_group_class_init (GtkActionGroupClass *klass)
+{
+ GObjectClass *gobject_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+
+ gobject_class->finalize = gtk_action_group_finalize;
+ gobject_class->set_property = gtk_action_group_set_property;
+ gobject_class->get_property = gtk_action_group_get_property;
+ klass->get_action = gtk_action_group_real_get_action;
+
+ /**
+ * GtkActionGroup:name:
+ *
+ * A name for the action.
+ *
+ * Deprecated: 3.10
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_NAME,
+ g_param_spec_string ("name",
+ P_("Name"),
+ P_("A name for the action group."),
+ NULL,
+ GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ /**
+ * GtkActionGroup:sensitive:
+ *
+ * Whether the action group is enabled.
+ *
+ * Deprecated: 3.10
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_SENSITIVE,
+ g_param_spec_boolean ("sensitive",
+ P_("Sensitive"),
+ P_("Whether the action group is enabled."),
+ TRUE,
+ GTK_PARAM_READWRITE));
+ /**
+ * GtkActionGroup:visible:
+ *
+ * Whether the action group is visible.
+ *
+ * Deprecated: 3.10
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_VISIBLE,
+ g_param_spec_boolean ("visible",
+ P_("Visible"),
+ P_("Whether the action group is visible."),
+ TRUE,
+ GTK_PARAM_READWRITE));
+ /**
+ * GtkActionGroup:accel-group:
+ *
+ * The accelerator group the actions of this group should use.
+ *
+ * Deprecated: 3.10
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_ACCEL_GROUP,
+ g_param_spec_object ("accel-group",
+ P_("Accelerator Group"),
+ P_("The accelerator group the actions of this group should use."),
+ GTK_TYPE_ACCEL_GROUP,
+ GTK_PARAM_READWRITE));
+
+ /**
+ * GtkActionGroup::connect-proxy:
+ * @action_group: the group
+ * @action: the action
+ * @proxy: the proxy
+ *
+ * The ::connect-proxy signal is emitted after connecting a proxy to
+ * an action in the group. Note that the proxy may have been connected
+ * to a different action before.
+ *
+ * This is intended for simple customizations for which a custom action
+ * class would be too clumsy, e.g. showing tooltips for menuitems in the
+ * statusbar.
+ *
+ * #GtkUIManager proxies the signal and provides global notification
+ * just before any action is connected to a proxy, which is probably more
+ * convenient to use.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+ action_group_signals[CONNECT_PROXY] =
+ g_signal_new (I_("connect-proxy"),
+ G_OBJECT_CLASS_TYPE (klass),
+ 0, 0, NULL, NULL,
+ _gtk_marshal_VOID__OBJECT_OBJECT,
+ G_TYPE_NONE, 2,
+ GTK_TYPE_ACTION, GTK_TYPE_WIDGET);
+
+ /**
+ * GtkActionGroup::disconnect-proxy:
+ * @action_group: the group
+ * @action: the action
+ * @proxy: the proxy
+ *
+ * The ::disconnect-proxy signal is emitted after disconnecting a proxy
+ * from an action in the group.
+ *
+ * #GtkUIManager proxies the signal and provides global notification
+ * just before any action is connected to a proxy, which is probably more
+ * convenient to use.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+ action_group_signals[DISCONNECT_PROXY] =
+ g_signal_new (I_("disconnect-proxy"),
+ G_OBJECT_CLASS_TYPE (klass),
+ 0, 0, NULL, NULL,
+ _gtk_marshal_VOID__OBJECT_OBJECT,
+ G_TYPE_NONE, 2,
+ GTK_TYPE_ACTION, GTK_TYPE_WIDGET);
+
+ /**
+ * GtkActionGroup::pre-activate:
+ * @action_group: the group
+ * @action: the action
+ *
+ * The ::pre-activate signal is emitted just before the @action in the
+ * @action_group is activated
+ *
+ * This is intended for #GtkUIManager to proxy the signal and provide global
+ * notification just before any action is activated.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+ action_group_signals[PRE_ACTIVATE] =
+ g_signal_new (I_("pre-activate"),
+ G_OBJECT_CLASS_TYPE (klass),
+ 0, 0, NULL, NULL,
+ _gtk_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ GTK_TYPE_ACTION);
+
+ /**
+ * GtkActionGroup::post-activate:
+ * @action_group: the group
+ * @action: the action
+ *
+ * The ::post-activate signal is emitted just after the @action in the
+ * @action_group is activated
+ *
+ * This is intended for #GtkUIManager to proxy the signal and provide global
+ * notification just after any action is activated.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+ action_group_signals[POST_ACTIVATE] =
+ g_signal_new (I_("post-activate"),
+ G_OBJECT_CLASS_TYPE (klass),
+ 0, 0, NULL, NULL,
+ _gtk_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ GTK_TYPE_ACTION);
+}
+
+
+static void
+remove_action (GtkAction *action)
+{
+ g_object_set (action, I_("action-group"), NULL, NULL);
+ g_object_unref (action);
+}
+
+static void
+gtk_action_group_init (GtkActionGroup *action_group)
+{
+ action_group->priv = gtk_action_group_get_instance_private (action_group);
+ action_group->priv->name = NULL;
+ action_group->priv->sensitive = TRUE;
+ action_group->priv->visible = TRUE;
+ action_group->priv->actions = g_hash_table_new_full (g_str_hash, g_str_equal,
+ NULL,
+ (GDestroyNotify) remove_action);
+ action_group->priv->translate_func = NULL;
+ action_group->priv->translate_data = NULL;
+ action_group->priv->translate_notify = NULL;
+}
+
+static void
+gtk_action_group_buildable_init (GtkBuildableIface *iface)
+{
+ iface->add_child = gtk_action_group_buildable_add_child;
+ iface->set_name = gtk_action_group_buildable_set_name;
+ iface->get_name = gtk_action_group_buildable_get_name;
+ iface->custom_tag_start = gtk_action_group_buildable_custom_tag_start;
+ iface->custom_tag_end = gtk_action_group_buildable_custom_tag_end;
+}
+
+static void
+gtk_action_group_buildable_add_child (GtkBuildable *buildable,
+ GtkBuilder *builder,
+ GObject *child,
+ const gchar *type)
+{
+ gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (buildable),
+ GTK_ACTION (child), NULL);
+}
+
+static void
+gtk_action_group_buildable_set_name (GtkBuildable *buildable,
+ const gchar *name)
+{
+ GtkActionGroup *self = GTK_ACTION_GROUP (buildable);
+ GtkActionGroupPrivate *private = self->priv;
+
+ private->name = g_strdup (name);
+}
+
+static const gchar *
+gtk_action_group_buildable_get_name (GtkBuildable *buildable)
+{
+ GtkActionGroup *self = GTK_ACTION_GROUP (buildable);
+ GtkActionGroupPrivate *private = self->priv;
+
+ return private->name;
+}
+
+typedef struct {
+ GObject *child;
+ guint key;
+ GdkModifierType modifiers;
+} AcceleratorParserData;
+
+static void
+accelerator_start_element (GMarkupParseContext *context,
+ const gchar *element_name,
+ const gchar **names,
+ const gchar **values,
+ gpointer user_data,
+ GError **error)
+{
+ gint i;
+ guint key = 0;
+ GdkModifierType modifiers = 0;
+ AcceleratorParserData *parser_data = (AcceleratorParserData*)user_data;
+
+ if (strcmp (element_name, "accelerator") != 0)
+ g_warning ("Unknown <accelerator> tag: %s", element_name);
+
+ for (i = 0; names[i]; i++)
+ {
+ if (strcmp (names[i], "key") == 0)
+ key = gdk_keyval_from_name (values[i]);
+ else if (strcmp (names[i], "modifiers") == 0)
+ {
+ if (!_gtk_builder_flags_from_string (GDK_TYPE_MODIFIER_TYPE,
+ values[i],
+ &modifiers,
+ error))
+ return;
+ }
+ }
+
+ if (key == 0)
+ {
+ g_warning ("<accelerator> requires a key attribute");
+ return;
+ }
+ parser_data->key = key;
+ parser_data->modifiers = modifiers;
+}
+
+static const GMarkupParser accelerator_parser =
+ {
+ accelerator_start_element
+ };
+
+static gboolean
+gtk_action_group_buildable_custom_tag_start (GtkBuildable *buildable,
+ GtkBuilder *builder,
+ GObject *child,
+ const gchar *tagname,
+ GMarkupParser *parser,
+ gpointer *user_data)
+{
+ AcceleratorParserData *parser_data;
+
+ if (child && strcmp (tagname, "accelerator") == 0)
+ {
+ parser_data = g_slice_new0 (AcceleratorParserData);
+ parser_data->child = child;
+ *user_data = parser_data;
+ *parser = accelerator_parser;
+
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static void
+gtk_action_group_buildable_custom_tag_end (GtkBuildable *buildable,
+ GtkBuilder *builder,
+ GObject *child,
+ const gchar *tagname,
+ gpointer *user_data)
+{
+ AcceleratorParserData *data;
+
+ if (strcmp (tagname, "accelerator") == 0)
+ {
+ GtkActionGroup *action_group;
+ GtkActionGroupPrivate *private;
+ GtkAction *action;
+ gchar *accel_path;
+
+ data = (AcceleratorParserData*)user_data;
+ action_group = GTK_ACTION_GROUP (buildable);
+ private = action_group->priv;
+ action = GTK_ACTION (child);
+
+ accel_path = g_strconcat ("<Actions>/",
+ private->name, "/",
+ gtk_action_get_name (action), NULL);
+
+ if (gtk_accel_map_lookup_entry (accel_path, NULL))
+ gtk_accel_map_change_entry (accel_path, data->key, data->modifiers, TRUE);
+ else
+ gtk_accel_map_add_entry (accel_path, data->key, data->modifiers);
+
+ gtk_action_set_accel_path (action, accel_path);
+
+ g_free (accel_path);
+ g_slice_free (AcceleratorParserData, data);
+ }
+}
+
+/**
+ * gtk_action_group_new:
+ * @name: the name of the action group.
+ *
+ * Creates a new #GtkActionGroup object. The name of the action group
+ * is used when associating <link linkend="Action-Accel">keybindings</link>
+ * with the actions.
+ *
+ * Returns: the new #GtkActionGroup
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+GtkActionGroup *
+gtk_action_group_new (const gchar *name)
+{
+ GtkActionGroup *self;
+ GtkActionGroupPrivate *private;
+
+ self = g_object_new (GTK_TYPE_ACTION_GROUP, NULL);
+ private = self->priv;
+ private->name = g_strdup (name);
+
+ return self;
+}
+
+static void
+gtk_action_group_finalize (GObject *object)
+{
+ GtkActionGroup *self = GTK_ACTION_GROUP (object);
+
+ g_free (self->priv->name);
+
+ g_hash_table_destroy (self->priv->actions);
+
+ g_clear_object (&self->priv->accel_group);
+
+ if (self->priv->translate_notify != NULL)
+ self->priv->translate_notify (self->priv->translate_data);
+
+ G_OBJECT_CLASS (gtk_action_group_parent_class)->finalize (object);
+}
+
+static void
+gtk_action_group_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GtkActionGroup *self;
+ GtkActionGroupPrivate *private;
+ gchar *tmp;
+
+ self = GTK_ACTION_GROUP (object);
+ private = self->priv;
+
+ switch (prop_id)
+ {
+ case PROP_NAME:
+ tmp = private->name;
+ private->name = g_value_dup_string (value);
+ g_free (tmp);
+ break;
+ case PROP_SENSITIVE:
+ gtk_action_group_set_sensitive (self, g_value_get_boolean (value));
+ break;
+ case PROP_VISIBLE:
+ gtk_action_group_set_visible (self, g_value_get_boolean (value));
+ break;
+ case PROP_ACCEL_GROUP:
+ gtk_action_group_set_accel_group (self, g_value_get_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gtk_action_group_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GtkActionGroup *self;
+ GtkActionGroupPrivate *private;
+
+ self = GTK_ACTION_GROUP (object);
+ private = self->priv;
+
+ switch (prop_id)
+ {
+ case PROP_NAME:
+ g_value_set_string (value, private->name);
+ break;
+ case PROP_SENSITIVE:
+ g_value_set_boolean (value, private->sensitive);
+ break;
+ case PROP_VISIBLE:
+ g_value_set_boolean (value, private->visible);
+ break;
+ case PROP_ACCEL_GROUP:
+ g_value_set_object (value, private->accel_group);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static GtkAction *
+gtk_action_group_real_get_action (GtkActionGroup *self,
+ const gchar *action_name)
+{
+ GtkActionGroupPrivate *private;
+
+ private = self->priv;
+
+ return g_hash_table_lookup (private->actions, action_name);
+}
+
+/**
+ * gtk_action_group_get_name:
+ * @action_group: the action group
+ *
+ * Gets the name of the action group.
+ *
+ * Returns: the name of the action group.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+const gchar *
+gtk_action_group_get_name (GtkActionGroup *action_group)
+{
+ GtkActionGroupPrivate *private;
+
+ g_return_val_if_fail (GTK_IS_ACTION_GROUP (action_group), NULL);
+
+ private = action_group->priv;
+
+ return private->name;
+}
+
+/**
+ * gtk_action_group_get_sensitive:
+ * @action_group: the action group
+ *
+ * Returns %TRUE if the group is sensitive. The constituent actions
+ * can only be logically sensitive (see gtk_action_is_sensitive()) if
+ * they are sensitive (see gtk_action_get_sensitive()) and their group
+ * is sensitive.
+ *
+ * Return value: %TRUE if the group is sensitive.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+gboolean
+gtk_action_group_get_sensitive (GtkActionGroup *action_group)
+{
+ GtkActionGroupPrivate *private;
+
+ g_return_val_if_fail (GTK_IS_ACTION_GROUP (action_group), FALSE);
+
+ private = action_group->priv;
+
+ return private->sensitive;
+}
+
+static void
+cb_set_action_sensitivity (const gchar *name,
+ GtkAction *action)
+{
+ /* Minor optimization, the action_groups state only affects actions
+ * that are themselves sensitive */
+ g_object_notify (G_OBJECT (action), "sensitive");
+
+}
+
+/**
+ * gtk_action_group_set_sensitive:
+ * @action_group: the action group
+ * @sensitive: new sensitivity
+ *
+ * Changes the sensitivity of @action_group
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_action_group_set_sensitive (GtkActionGroup *action_group,
+ gboolean sensitive)
+{
+ GtkActionGroupPrivate *private;
+
+ g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
+
+ private = action_group->priv;
+ sensitive = sensitive != FALSE;
+
+ if (private->sensitive != sensitive)
+ {
+ private->sensitive = sensitive;
+ g_hash_table_foreach (private->actions,
+ (GHFunc) cb_set_action_sensitivity, NULL);
+
+ g_object_notify (G_OBJECT (action_group), "sensitive");
+ }
+}
+
+/**
+ * gtk_action_group_get_visible:
+ * @action_group: the action group
+ *
+ * Returns %TRUE if the group is visible. The constituent actions
+ * can only be logically visible (see gtk_action_is_visible()) if
+ * they are visible (see gtk_action_get_visible()) and their group
+ * is visible.
+ *
+ * Return value: %TRUE if the group is visible.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+gboolean
+gtk_action_group_get_visible (GtkActionGroup *action_group)
+{
+ GtkActionGroupPrivate *private;
+
+ g_return_val_if_fail (GTK_IS_ACTION_GROUP (action_group), FALSE);
+
+ private = action_group->priv;
+
+ return private->visible;
+}
+
+/**
+ * gtk_action_group_get_accel_group:
+ * @action_group: a #GtkActionGroup
+ *
+ * Gets the accelerator group.
+ *
+ * Returns: (transfer none): the accelerator group associated with this action
+ * group or %NULL if there is none.
+ *
+ * Since: 3.6
+ *
+ * Deprecated: 3.10
+ */
+GtkAccelGroup *
+gtk_action_group_get_accel_group (GtkActionGroup *action_group)
+{
+ g_return_val_if_fail (GTK_IS_ACTION_GROUP (action_group), FALSE);
+
+ return action_group->priv->accel_group;
+}
+
+static void
+cb_set_action_visiblity (const gchar *name,
+ GtkAction *action)
+{
+ /* Minor optimization, the action_groups state only affects actions
+ * that are themselves visible */
+ g_object_notify (G_OBJECT (action), "visible");
+}
+
+/**
+ * gtk_action_group_set_visible:
+ * @action_group: the action group
+ * @visible: new visiblity
+ *
+ * Changes the visible of @action_group.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_action_group_set_visible (GtkActionGroup *action_group,
+ gboolean visible)
+{
+ GtkActionGroupPrivate *private;
+
+ g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
+
+ private = action_group->priv;
+ visible = visible != FALSE;
+
+ if (private->visible != visible)
+ {
+ private->visible = visible;
+ g_hash_table_foreach (private->actions,
+ (GHFunc) cb_set_action_visiblity, NULL);
+
+ g_object_notify (G_OBJECT (action_group), "visible");
+ }
+}
+
+static void
+gtk_action_group_accel_group_foreach (gpointer key, gpointer val, gpointer data)
+{
+ gtk_action_set_accel_group (val, data);
+}
+
+/**
+ * gtk_action_group_set_accel_group:
+ * @action_group: a #GtkActionGroup
+ * @accel_group: (allow-none): a #GtkAccelGroup to set or %NULL
+ *
+ * Sets the accelerator group to be used by every action in this group.
+ *
+ * Since: 3.6
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_action_group_set_accel_group (GtkActionGroup *action_group,
+ GtkAccelGroup *accel_group)
+{
+ GtkActionGroupPrivate *private;
+
+ g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
+
+ private = action_group->priv;
+
+ if (private->accel_group == accel_group)
+ return;
+
+ g_clear_object (&private->accel_group);
+
+ if (accel_group)
+ private->accel_group = g_object_ref (accel_group);
+
+ /* Set the new accel group on every action */
+ g_hash_table_foreach (private->actions,
+ gtk_action_group_accel_group_foreach,
+ accel_group);
+
+ g_object_notify (G_OBJECT (action_group), "accel-group");
+}
+
+/**
+ * gtk_action_group_get_action:
+ * @action_group: the action group
+ * @action_name: the name of the action
+ *
+ * Looks up an action in the action group by name.
+ *
+ * Returns: (transfer none): the action, or %NULL if no action by that name exists
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+GtkAction *
+gtk_action_group_get_action (GtkActionGroup *action_group,
+ const gchar *action_name)
+{
+ g_return_val_if_fail (GTK_IS_ACTION_GROUP (action_group), NULL);
+ g_return_val_if_fail (GTK_ACTION_GROUP_GET_CLASS (action_group)->get_action != NULL, NULL);
+
+ return GTK_ACTION_GROUP_GET_CLASS (action_group)->get_action (action_group,
+ action_name);
+}
+
+static gboolean
+check_unique_action (GtkActionGroup *action_group,
+ const gchar *action_name)
+{
+ if (gtk_action_group_get_action (action_group, action_name) != NULL)
+ {
+ GtkActionGroupPrivate *private;
+
+ private = action_group->priv;
+
+ g_warning ("Refusing to add non-unique action '%s' to action group '%s'",
+ action_name,
+ private->name);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/**
+ * gtk_action_group_add_action:
+ * @action_group: the action group
+ * @action: an action
+ *
+ * Adds an action object to the action group. Note that this function
+ * does not set up the accel path of the action, which can lead to problems
+ * if a user tries to modify the accelerator of a menuitem associated with
+ * the action. Therefore you must either set the accel path yourself with
+ * gtk_action_set_accel_path(), or use
+ * <literal>gtk_action_group_add_action_with_accel (..., NULL)</literal>.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_action_group_add_action (GtkActionGroup *action_group,
+ GtkAction *action)
+{
+ GtkActionGroupPrivate *private;
+ const gchar *name;
+
+ g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ name = gtk_action_get_name (action);
+ g_return_if_fail (name != NULL);
+
+ if (!check_unique_action (action_group, name))
+ return;
+
+ private = action_group->priv;
+
+ g_hash_table_insert (private->actions,
+ (gpointer) name,
+ g_object_ref (action));
+ g_object_set (action, I_("action-group"), action_group, NULL);
+
+ if (private->accel_group)
+ gtk_action_set_accel_group (action, private->accel_group);
+}
+
+/**
+ * gtk_action_group_add_action_with_accel:
+ * @action_group: the action group
+ * @action: the action to add
+ * @accelerator: (allow-none): the accelerator for the action, in
+ * the format understood by gtk_accelerator_parse(), or "" for no accelerator, or
+ * %NULL to use the stock accelerator
+ *
+ * Adds an action object to the action group and sets up the accelerator.
+ *
+ * If @accelerator is %NULL, attempts to use the accelerator associated
+ * with the stock_id of the action.
+ *
+ * Accel paths are set to
+ * <literal><Actions>/<replaceable>group-name</replaceable>/<replaceable>action-name</replaceable></literal>.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_action_group_add_action_with_accel (GtkActionGroup *action_group,
+ GtkAction *action,
+ const gchar *accelerator)
+{
+ GtkActionGroupPrivate *private;
+ gchar *accel_path;
+ guint accel_key = 0;
+ GdkModifierType accel_mods;
+ const gchar *name;
+
+ name = gtk_action_get_name (action);
+ if (!check_unique_action (action_group, name))
+ return;
+
+ private = action_group->priv;
+ accel_path = g_strconcat ("<Actions>/",
+ private->name, "/", name, NULL);
+
+ if (accelerator)
+ {
+ if (accelerator[0] == 0)
+ accel_key = 0;
+ else
+ {
+ gtk_accelerator_parse (accelerator, &accel_key, &accel_mods);
+ if (accel_key == 0)
+ g_warning ("Unable to parse accelerator '%s' for action '%s'",
+ accelerator, name);
+ }
+ }
+ else
+ {
+ gchar *stock_id;
+ GtkStockItem stock_item;
+
+ g_object_get (action, "stock-id", &stock_id, NULL);
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+
+ if (stock_id && gtk_stock_lookup (stock_id, &stock_item))
+ {
+ accel_key = stock_item.keyval;
+ accel_mods = stock_item.modifier;
+ }
+
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+
+ g_free (stock_id);
+ }
+
+ if (accel_key)
+ gtk_accel_map_add_entry (accel_path, accel_key, accel_mods);
+
+ gtk_action_set_accel_path (action, accel_path);
+ gtk_action_group_add_action (action_group, action);
+
+ g_free (accel_path);
+}
+
+/**
+ * gtk_action_group_remove_action:
+ * @action_group: the action group
+ * @action: an action
+ *
+ * Removes an action object from the action group.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_action_group_remove_action (GtkActionGroup *action_group,
+ GtkAction *action)
+{
+ GtkActionGroupPrivate *private;
+ const gchar *name;
+
+ g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ name = gtk_action_get_name (action);
+ g_return_if_fail (name != NULL);
+
+ private = action_group->priv;
+
+ g_hash_table_remove (private->actions, name);
+}
+
+static void
+add_single_action (gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ GList **list = user_data;
+
+ *list = g_list_prepend (*list, value);
+}
+
+/**
+ * gtk_action_group_list_actions:
+ * @action_group: the action group
+ *
+ * Lists the actions in the action group.
+ *
+ * Returns: (element-type GtkAction) (transfer container): an allocated list of the action objects in the action group
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+GList *
+gtk_action_group_list_actions (GtkActionGroup *action_group)
+{
+ GtkActionGroupPrivate *private;
+ GList *actions = NULL;
+
+ g_return_val_if_fail (GTK_IS_ACTION_GROUP (action_group), NULL);
+
+ private = action_group->priv;
+
+ g_hash_table_foreach (private->actions, add_single_action, &actions);
+
+ return g_list_reverse (actions);
+}
+
+
+/**
+ * gtk_action_group_add_actions: (skip)
+ * @action_group: the action group
+ * @entries: (array length=n_entries): an array of action descriptions
+ * @n_entries: the number of entries
+ * @user_data: data to pass to the action callbacks
+ *
+ * This is a convenience function to create a number of actions and add them
+ * to the action group.
+ *
+ * The "activate" signals of the actions are connected to the callbacks and
+ * their accel paths are set to
+ * <literal><Actions>/<replaceable>group-name</replaceable>/<replaceable>action-name</replaceable></literal>.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_action_group_add_actions (GtkActionGroup *action_group,
+ const GtkActionEntry *entries,
+ guint n_entries,
+ gpointer user_data)
+{
+ gtk_action_group_add_actions_full (action_group,
+ entries, n_entries,
+ user_data, NULL);
+}
+
+typedef struct _SharedData SharedData;
+
+struct _SharedData {
+ guint ref_count;
+ gpointer data;
+ GDestroyNotify destroy;
+};
+
+static void
+shared_data_unref (gpointer data)
+{
+ SharedData *shared_data = (SharedData *)data;
+
+ shared_data->ref_count--;
+ if (shared_data->ref_count == 0)
+ {
+ if (shared_data->destroy)
+ shared_data->destroy (shared_data->data);
+
+ g_slice_free (SharedData, shared_data);
+ }
+}
+
+
+/**
+ * gtk_action_group_add_actions_full: (skip)
+ * @action_group: the action group
+ * @entries: (array length=n_entries): an array of action descriptions
+ * @n_entries: the number of entries
+ * @user_data: data to pass to the action callbacks
+ * @destroy: destroy notification callback for @user_data
+ *
+ * This variant of gtk_action_group_add_actions() adds a #GDestroyNotify
+ * callback for @user_data.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_action_group_add_actions_full (GtkActionGroup *action_group,
+ const GtkActionEntry *entries,
+ guint n_entries,
+ gpointer user_data,
+ GDestroyNotify destroy)
+{
+
+ /* Keep this in sync with the other
+ * gtk_action_group_add_..._actions_full() functions.
+ */
+ guint i;
+ SharedData *shared_data;
+
+ g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
+
+ shared_data = g_slice_new0 (SharedData);
+ shared_data->ref_count = 1;
+ shared_data->data = user_data;
+ shared_data->destroy = destroy;
+
+ for (i = 0; i < n_entries; i++)
+ {
+ GtkAction *action;
+ const gchar *label;
+ const gchar *tooltip;
+
+ if (!check_unique_action (action_group, entries[i].name))
+ continue;
+
+ label = gtk_action_group_translate_string (action_group, entries[i].label);
+ tooltip = gtk_action_group_translate_string (action_group, entries[i].tooltip);
+
+ action = gtk_action_new (entries[i].name,
+ label,
+ tooltip,
+ NULL);
+
+ if (entries[i].stock_id)
+ {
+ g_object_set (action, "stock-id", entries[i].stock_id, NULL);
+ if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default (),
+ entries[i].stock_id))
+ g_object_set (action, "icon-name", entries[i].stock_id, NULL);
+ }
+
+ if (entries[i].callback)
+ {
+ GClosure *closure;
+
+ closure = g_cclosure_new (entries[i].callback, user_data, NULL);
+ g_closure_add_finalize_notifier (closure, shared_data,
+ (GClosureNotify)shared_data_unref);
+ shared_data->ref_count++;
+
+ g_signal_connect_closure (action, "activate", closure, FALSE);
+ }
+
+ gtk_action_group_add_action_with_accel (action_group,
+ action,
+ entries[i].accelerator);
+ g_object_unref (action);
+ }
+
+ shared_data_unref (shared_data);
+}
+
+/**
+ * gtk_action_group_add_toggle_actions: (skip)
+ * @action_group: the action group
+ * @entries: (array length=n_entries): an array of toggle action descriptions
+ * @n_entries: the number of entries
+ * @user_data: data to pass to the action callbacks
+ *
+ * This is a convenience function to create a number of toggle actions and add them
+ * to the action group.
+ *
+ * The "activate" signals of the actions are connected to the callbacks and
+ * their accel paths are set to
+ * <literal><Actions>/<replaceable>group-name</replaceable>/<replaceable>action-name</replaceable></literal>.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_action_group_add_toggle_actions (GtkActionGroup *action_group,
+ const GtkToggleActionEntry *entries,
+ guint n_entries,
+ gpointer user_data)
+{
+ gtk_action_group_add_toggle_actions_full (action_group,
+ entries, n_entries,
+ user_data, NULL);
+}
+
+
+/**
+ * gtk_action_group_add_toggle_actions_full: (skip)
+ * @action_group: the action group
+ * @entries: (array length=n_entries): an array of toggle action descriptions
+ * @n_entries: the number of entries
+ * @user_data: data to pass to the action callbacks
+ * @destroy: destroy notification callback for @user_data
+ *
+ * This variant of gtk_action_group_add_toggle_actions() adds a
+ * #GDestroyNotify callback for @user_data.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_group,
+ const GtkToggleActionEntry *entries,
+ guint n_entries,
+ gpointer user_data,
+ GDestroyNotify destroy)
+{
+ /* Keep this in sync with the other
+ * gtk_action_group_add_..._actions_full() functions.
+ */
+ guint i;
+ SharedData *shared_data;
+
+ g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
+
+ shared_data = g_slice_new0 (SharedData);
+ shared_data->ref_count = 1;
+ shared_data->data = user_data;
+ shared_data->destroy = destroy;
+
+ for (i = 0; i < n_entries; i++)
+ {
+ GtkToggleAction *action;
+ const gchar *label;
+ const gchar *tooltip;
+
+ if (!check_unique_action (action_group, entries[i].name))
+ continue;
+
+ label = gtk_action_group_translate_string (action_group, entries[i].label);
+ tooltip = gtk_action_group_translate_string (action_group, entries[i].tooltip);
+
+ action = gtk_toggle_action_new (entries[i].name,
+ label,
+ tooltip,
+ NULL);
+
+ if (entries[i].stock_id)
+ {
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+
+ if (gtk_icon_factory_lookup_default (entries[i].stock_id))
+ g_object_set (action, "stock-id", entries[i].stock_id, NULL);
+ else
+ g_object_set (action, "icon-name", entries[i].stock_id, NULL);
+
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+ }
+
+ gtk_toggle_action_set_active (action, entries[i].is_active);
+
+ if (entries[i].callback)
+ {
+ GClosure *closure;
+
+ closure = g_cclosure_new (entries[i].callback, user_data, NULL);
+ g_closure_add_finalize_notifier (closure, shared_data,
+ (GClosureNotify)shared_data_unref);
+ shared_data->ref_count++;
+
+ g_signal_connect_closure (action, "activate", closure, FALSE);
+ }
+
+ gtk_action_group_add_action_with_accel (action_group,
+ GTK_ACTION (action),
+ entries[i].accelerator);
+ g_object_unref (action);
+ }
+
+ shared_data_unref (shared_data);
+}
+
+/**
+ * gtk_action_group_add_radio_actions: (skip)
+ * @action_group: the action group
+ * @entries: (array length=n_entries): an array of radio action descriptions
+ * @n_entries: the number of entries
+ * @value: the value of the action to activate initially, or -1 if
+ * no action should be activated
+ * @on_change: the callback to connect to the changed signal
+ * @user_data: data to pass to the action callbacks
+ *
+ * This is a convenience routine to create a group of radio actions and
+ * add them to the action group.
+ *
+ * The "changed" signal of the first radio action is connected to the
+ * @on_change callback and the accel paths of the actions are set to
+ * <literal><Actions>/<replaceable>group-name</replaceable>/<replaceable>action-name</replaceable></literal>.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+void
+gtk_action_group_add_radio_actions (GtkActionGroup *action_group,
+ const GtkRadioActionEntry *entries,
+ guint n_entries,
+ gint value,
+ GCallback on_change,
+ gpointer user_data)
+{
+ gtk_action_group_add_radio_actions_full (action_group,
+ entries, n_entries,
+ value,
+ on_change, user_data, NULL);
+}
+
+/**
+ * gtk_action_group_add_radio_actions_full: (skip)
+ * @action_group: the action group
+ * @entries: (array length=n_entries): an array of radio action descriptions
+ * @n_entries: the number of entries
+ * @value: the value of the action to activate initially, or -1 if
+ * no action should be activated
+ * @on_change: the callback to connect to the changed signal
+ * @user_data: data to pass to the action callbacks
+ * @destroy: destroy notification callback for @user_data
+ *
+ * This variant of gtk_action_group_add_radio_actions() adds a
+ * #GDestroyNotify callback for @user_data.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+void
+gtk_action_group_add_radio_actions_full (GtkActionGroup *action_group,
+ const GtkRadioActionEntry *entries,
+ guint n_entries,
+ gint value,
+ GCallback on_change,
+ gpointer user_data,
+ GDestroyNotify destroy)
+{
+ /* Keep this in sync with the other
+ * gtk_action_group_add_..._actions_full() functions.
+ */
+ guint i;
+ GSList *group = NULL;
+ GtkRadioAction *first_action = NULL;
+
+ g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
+
+ for (i = 0; i < n_entries; i++)
+ {
+ GtkRadioAction *action;
+ const gchar *label;
+ const gchar *tooltip;
+
+ if (!check_unique_action (action_group, entries[i].name))
+ continue;
+
+ label = gtk_action_group_translate_string (action_group, entries[i].label);
+ tooltip = gtk_action_group_translate_string (action_group, entries[i].tooltip);
+
+ action = gtk_radio_action_new (entries[i].name,
+ label,
+ tooltip,
+ NULL,
+ entries[i].value);
+
+ if (entries[i].stock_id)
+ {
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+
+ if (gtk_icon_factory_lookup_default (entries[i].stock_id))
+ g_object_set (action, "stock-id", entries[i].stock_id, NULL);
+ else
+ g_object_set (action, "icon-name", entries[i].stock_id, NULL);
+
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+ }
+
+ if (i == 0)
+ first_action = action;
+
+ gtk_radio_action_set_group (action, group);
+ group = gtk_radio_action_get_group (action);
+
+ if (value == entries[i].value)
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
+
+ gtk_action_group_add_action_with_accel (action_group,
+ GTK_ACTION (action),
+ entries[i].accelerator);
+ g_object_unref (action);
+ }
+
+ if (on_change && first_action)
+ g_signal_connect_data (first_action, "changed",
+ on_change, user_data,
+ (GClosureNotify)destroy, 0);
+}
+
+/**
+ * gtk_action_group_set_translate_func:
+ * @action_group: a #GtkActionGroup
+ * @func: a #GtkTranslateFunc
+ * @data: data to be passed to @func and @notify
+ * @notify: a #GDestroyNotify function to be called when @action_group is
+ * destroyed and when the translation function is changed again
+ *
+ * Sets a function to be used for translating the @label and @tooltip of
+ * #GtkActionEntry<!-- -->s added by gtk_action_group_add_actions().
+ *
+ * If you're using gettext(), it is enough to set the translation domain
+ * with gtk_action_group_set_translation_domain().
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+void
+gtk_action_group_set_translate_func (GtkActionGroup *action_group,
+ GtkTranslateFunc func,
+ gpointer data,
+ GDestroyNotify notify)
+{
+ GtkActionGroupPrivate *private;
+
+ g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
+
+ private = action_group->priv;
+
+ if (private->translate_notify)
+ private->translate_notify (private->translate_data);
+
+ private->translate_func = func;
+ private->translate_data = data;
+ private->translate_notify = notify;
+}
+
+static gchar *
+dgettext_swapped (const gchar *msgid,
+ const gchar *domainname)
+{
+ /* Pass through g_dgettext if and only if msgid is nonempty. */
+ if (msgid && *msgid)
+ return (gchar*) g_dgettext (domainname, msgid);
+ else
+ return (gchar*) msgid;
+}
+
+/**
+ * gtk_action_group_set_translation_domain:
+ * @action_group: a #GtkActionGroup
+ * @domain: (allow-none): the translation domain to use for g_dgettext()
+ * calls, or %NULL to use the domain set with textdomain()
+ *
+ * Sets the translation domain and uses g_dgettext() for translating the
+ * @label and @tooltip of #GtkActionEntry<!-- -->s added by
+ * gtk_action_group_add_actions().
+ *
+ * If you're not using gettext() for localization, see
+ * gtk_action_group_set_translate_func().
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+void
+gtk_action_group_set_translation_domain (GtkActionGroup *action_group,
+ const gchar *domain)
+{
+ g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
+
+ gtk_action_group_set_translate_func (action_group,
+ (GtkTranslateFunc)dgettext_swapped,
+ g_strdup (domain),
+ g_free);
+}
+
+
+/**
+ * gtk_action_group_translate_string:
+ * @action_group: a #GtkActionGroup
+ * @string: a string
+ *
+ * Translates a string using the function set with
+ * gtk_action_group_set_translate_func(). This
+ * is mainly intended for language bindings.
+ *
+ * Returns: the translation of @string
+ *
+ * Since: 2.6
+ *
+ * Deprecated: 3.10
+ **/
+const gchar *
+gtk_action_group_translate_string (GtkActionGroup *action_group,
+ const gchar *string)
+{
+ GtkActionGroupPrivate *private;
+ GtkTranslateFunc translate_func;
+ gpointer translate_data;
+
+ g_return_val_if_fail (GTK_IS_ACTION_GROUP (action_group), string);
+
+ if (string == NULL)
+ return NULL;
+
+ private = action_group->priv;
+
+ translate_func = private->translate_func;
+ translate_data = private->translate_data;
+
+ if (translate_func)
+ return translate_func (string, translate_data);
+ else
+ return string;
+}
+
+/* Protected for use by GtkAction */
+void
+_gtk_action_group_emit_connect_proxy (GtkActionGroup *action_group,
+ GtkAction *action,
+ GtkWidget *proxy)
+{
+ g_signal_emit (action_group, action_group_signals[CONNECT_PROXY], 0,
+ action, proxy);
+}
+
+void
+_gtk_action_group_emit_disconnect_proxy (GtkActionGroup *action_group,
+ GtkAction *action,
+ GtkWidget *proxy)
+{
+ g_signal_emit (action_group, action_group_signals[DISCONNECT_PROXY], 0,
+ action, proxy);
+}
+
+void
+_gtk_action_group_emit_pre_activate (GtkActionGroup *action_group,
+ GtkAction *action)
+{
+ g_signal_emit (action_group, action_group_signals[PRE_ACTIVATE], 0, action);
+}
+
+void
+_gtk_action_group_emit_post_activate (GtkActionGroup *action_group,
+ GtkAction *action)
+{
+ g_signal_emit (action_group, action_group_signals[POST_ACTIVATE], 0, action);
+}
--- /dev/null
+/*
+ * GTK - The GIMP Toolkit
+ * Copyright (C) 1998, 1999 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Author: James Henstridge <james@daa.com.au>
+ *
+ * Modified by the GTK+ Team and others 2003. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __GTK_ACTION_GROUP_H__
+#define __GTK_ACTION_GROUP_H__
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#include <gtk/deprecated/gtkaction.h>
+#include <gtk/deprecated/gtkstock.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_ACTION_GROUP (gtk_action_group_get_type ())
+#define GTK_ACTION_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ACTION_GROUP, GtkActionGroup))
+#define GTK_ACTION_GROUP_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), GTK_TYPE_ACTION_GROUP, GtkActionGroupClass))
+#define GTK_IS_ACTION_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ACTION_GROUP))
+#define GTK_IS_ACTION_GROUP_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), GTK_TYPE_ACTION_GROUP))
+#define GTK_ACTION_GROUP_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), GTK_TYPE_ACTION_GROUP, GtkActionGroupClass))
+
+typedef struct _GtkActionGroup GtkActionGroup;
+typedef struct _GtkActionGroupPrivate GtkActionGroupPrivate;
+typedef struct _GtkActionGroupClass GtkActionGroupClass;
+typedef struct _GtkActionEntry GtkActionEntry;
+typedef struct _GtkToggleActionEntry GtkToggleActionEntry;
+typedef struct _GtkRadioActionEntry GtkRadioActionEntry;
+
+struct _GtkActionGroup
+{
+ GObject parent;
+
+ /*< private >*/
+ GtkActionGroupPrivate *priv;
+};
+
+struct _GtkActionGroupClass
+{
+ GObjectClass parent_class;
+
+ GtkAction *(* get_action) (GtkActionGroup *action_group,
+ const gchar *action_name);
+
+ /* Padding for future expansion */
+ void (*_gtk_reserved1) (void);
+ void (*_gtk_reserved2) (void);
+ void (*_gtk_reserved3) (void);
+ void (*_gtk_reserved4) (void);
+};
+
+/**
+ * GtkActionEntry:
+ * @name: The name of the action.
+ * @stock_id: The stock id for the action, or the name of an icon from the
+ * icon theme.
+ * @label: The label for the action. This field should typically be marked
+ * for translation, see gtk_action_group_set_translation_domain(). If
+ * @label is %NULL, the label of the stock item with id @stock_id is used.
+ * @accelerator: The accelerator for the action, in the format understood by
+ * gtk_accelerator_parse().
+ * @tooltip: The tooltip for the action. This field should typically be
+ * marked for translation, see gtk_action_group_set_translation_domain().
+ * @callback: The function to call when the action is activated.
+ *
+ * #GtkActionEntry structs are used with gtk_action_group_add_actions() to
+ * construct actions.
+ *
+ * Deprecated: 3.10
+ */
+struct _GtkActionEntry
+{
+ const gchar *name;
+ const gchar *stock_id;
+ const gchar *label;
+ const gchar *accelerator;
+ const gchar *tooltip;
+ GCallback callback;
+};
+
+/**
+ * GtkToggleActionEntry:
+ * @name: The name of the action.
+ * @stock_id: The stock id for the action, or the name of an icon from the
+ * icon theme.
+ * @label: The label for the action. This field should typically be marked
+ * for translation, see gtk_action_group_set_translation_domain().
+ * @accelerator: The accelerator for the action, in the format understood by
+ * gtk_accelerator_parse().
+ * @tooltip: The tooltip for the action. This field should typically be
+ * marked for translation, see gtk_action_group_set_translation_domain().
+ * @callback: The function to call when the action is activated.
+ * @is_active: The initial state of the toggle action.
+ *
+ * #GtkToggleActionEntry structs are used with
+ * gtk_action_group_add_toggle_actions() to construct toggle actions.
+ *
+ * Deprecated: 3.10
+ */
+struct _GtkToggleActionEntry
+{
+ const gchar *name;
+ const gchar *stock_id;
+ const gchar *label;
+ const gchar *accelerator;
+ const gchar *tooltip;
+ GCallback callback;
+ gboolean is_active;
+};
+
+/**
+ * GtkRadioActionEntry:
+ * @name: The name of the action.
+ * @stock_id: The stock id for the action, or the name of an icon from the
+ * icon theme.
+ * @label: The label for the action. This field should typically be marked
+ * for translation, see gtk_action_group_set_translation_domain().
+ * @accelerator: The accelerator for the action, in the format understood by
+ * gtk_accelerator_parse().
+ * @tooltip: The tooltip for the action. This field should typically be
+ * marked for translation, see gtk_action_group_set_translation_domain().
+ * @value: The value to set on the radio action. See
+ * gtk_radio_action_get_current_value().
+ *
+ * #GtkRadioActionEntry structs are used with
+ * gtk_action_group_add_radio_actions() to construct groups of radio actions.
+ *
+ * Deprecated: 3.10
+ */
+struct _GtkRadioActionEntry
+{
+ const gchar *name;
+ const gchar *stock_id;
+ const gchar *label;
+ const gchar *accelerator;
+ const gchar *tooltip;
+ gint value;
+};
+
+GDK_DEPRECATED_IN_3_10
+GType gtk_action_group_get_type (void) G_GNUC_CONST;
+GDK_DEPRECATED_IN_3_10
+GtkActionGroup *gtk_action_group_new (const gchar *name);
+GDK_DEPRECATED_IN_3_10
+const gchar *gtk_action_group_get_name (GtkActionGroup *action_group);
+GDK_DEPRECATED_IN_3_10
+gboolean gtk_action_group_get_sensitive (GtkActionGroup *action_group);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_group_set_sensitive (GtkActionGroup *action_group,
+ gboolean sensitive);
+GDK_DEPRECATED_IN_3_10
+gboolean gtk_action_group_get_visible (GtkActionGroup *action_group);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_group_set_visible (GtkActionGroup *action_group,
+ gboolean visible);
+GDK_DEPRECATED_IN_3_10
+GtkAccelGroup *gtk_action_group_get_accel_group (GtkActionGroup *action_group);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_group_set_accel_group (GtkActionGroup *action_group,
+ GtkAccelGroup *accel_group);
+
+GDK_DEPRECATED_IN_3_10
+GtkAction *gtk_action_group_get_action (GtkActionGroup *action_group,
+ const gchar *action_name);
+GDK_DEPRECATED_IN_3_10
+GList *gtk_action_group_list_actions (GtkActionGroup *action_group);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_group_add_action (GtkActionGroup *action_group,
+ GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_group_add_action_with_accel (GtkActionGroup *action_group,
+ GtkAction *action,
+ const gchar *accelerator);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_group_remove_action (GtkActionGroup *action_group,
+ GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_group_add_actions (GtkActionGroup *action_group,
+ const GtkActionEntry *entries,
+ guint n_entries,
+ gpointer user_data);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_group_add_toggle_actions (GtkActionGroup *action_group,
+ const GtkToggleActionEntry *entries,
+ guint n_entries,
+ gpointer user_data);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_group_add_radio_actions (GtkActionGroup *action_group,
+ const GtkRadioActionEntry *entries,
+ guint n_entries,
+ gint value,
+ GCallback on_change,
+ gpointer user_data);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_group_add_actions_full (GtkActionGroup *action_group,
+ const GtkActionEntry *entries,
+ guint n_entries,
+ gpointer user_data,
+ GDestroyNotify destroy);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_group,
+ const GtkToggleActionEntry *entries,
+ guint n_entries,
+ gpointer user_data,
+ GDestroyNotify destroy);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_group_add_radio_actions_full (GtkActionGroup *action_group,
+ const GtkRadioActionEntry *entries,
+ guint n_entries,
+ gint value,
+ GCallback on_change,
+ gpointer user_data,
+ GDestroyNotify destroy);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_group_set_translate_func (GtkActionGroup *action_group,
+ GtkTranslateFunc func,
+ gpointer data,
+ GDestroyNotify notify);
+GDK_DEPRECATED_IN_3_10
+void gtk_action_group_set_translation_domain (GtkActionGroup *action_group,
+ const gchar *domain);
+GDK_DEPRECATED_IN_3_10
+const gchar * gtk_action_group_translate_string (GtkActionGroup *action_group,
+ const gchar *string);
+
+/* Protected for use by GtkAction */
+void _gtk_action_group_emit_connect_proxy (GtkActionGroup *action_group,
+ GtkAction *action,
+ GtkWidget *proxy);
+void _gtk_action_group_emit_disconnect_proxy (GtkActionGroup *action_group,
+ GtkAction *action,
+ GtkWidget *proxy);
+void _gtk_action_group_emit_pre_activate (GtkActionGroup *action_group,
+ GtkAction *action);
+void _gtk_action_group_emit_post_activate (GtkActionGroup *action_group,
+ GtkAction *action);
+
+G_END_DECLS
+
+#endif /* __GTK_ACTION_GROUP_H__ */
--- /dev/null
+/* gtkactivatable.c
+ * Copyright (C) 2008 Tristan Van Berkom <tristan.van.berkom@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * SECTION:gtkactivatable
+ * @Short_Description: An interface for activatable widgets
+ * @Title: GtkActivatable
+ *
+ * Activatable widgets can be connected to a #GtkAction and reflects
+ * the state of its action. A #GtkActivatable can also provide feedback
+ * through its action, as they are responsible for activating their
+ * related actions.
+ *
+ * <refsect2>
+ * <title>Implementing GtkActivatable</title>
+ * <para>
+ * When extending a class that is already #GtkActivatable; it is only
+ * necessary to implement the #GtkActivatable->sync_action_properties()
+ * and #GtkActivatable->update() methods and chain up to the parent
+ * implementation, however when introducing
+ * a new #GtkActivatable class; the #GtkActivatable:related-action and
+ * #GtkActivatable:use-action-appearance properties need to be handled by
+ * the implementor. Handling these properties is mostly a matter of installing
+ * the action pointer and boolean flag on your instance, and calling
+ * gtk_activatable_do_set_related_action() and
+ * gtk_activatable_sync_action_properties() at the appropriate times.
+ * </para>
+ * <example>
+ * <title>A class fragment implementing #GtkActivatable</title>
+ * <programlisting><![CDATA[
+ *
+ * enum {
+ * ...
+ *
+ * PROP_ACTIVATABLE_RELATED_ACTION,
+ * PROP_ACTIVATABLE_USE_ACTION_APPEARANCE
+ * }
+ *
+ * struct _FooBarPrivate
+ * {
+ *
+ * ...
+ *
+ * GtkAction *action;
+ * gboolean use_action_appearance;
+ * };
+ *
+ * ...
+ *
+ * static void foo_bar_activatable_interface_init (GtkActivatableIface *iface);
+ * static void foo_bar_activatable_update (GtkActivatable *activatable,
+ * GtkAction *action,
+ * const gchar *property_name);
+ * static void foo_bar_activatable_sync_action_properties (GtkActivatable *activatable,
+ * GtkAction *action);
+ * ...
+ *
+ *
+ * static void
+ * foo_bar_class_init (FooBarClass *klass)
+ * {
+ *
+ * ...
+ *
+ * g_object_class_override_property (gobject_class, PROP_ACTIVATABLE_RELATED_ACTION, "related-action");
+ * g_object_class_override_property (gobject_class, PROP_ACTIVATABLE_USE_ACTION_APPEARANCE, "use-action-appearance");
+ *
+ * ...
+ * }
+ *
+ *
+ * static void
+ * foo_bar_activatable_interface_init (GtkActivatableIface *iface)
+ * {
+ * iface->update = foo_bar_activatable_update;
+ * iface->sync_action_properties = foo_bar_activatable_sync_action_properties;
+ * }
+ *
+ * ... Break the reference using gtk_activatable_do_set_related_action()...
+ *
+ * static void
+ * foo_bar_dispose (GObject *object)
+ * {
+ * FooBar *bar = FOO_BAR (object);
+ * FooBarPrivate *priv = FOO_BAR_GET_PRIVATE (bar);
+ *
+ * ...
+ *
+ * if (priv->action)
+ * {
+ * gtk_activatable_do_set_related_action (GTK_ACTIVATABLE (bar), NULL);
+ * priv->action = NULL;
+ * }
+ * G_OBJECT_CLASS (foo_bar_parent_class)->dispose (object);
+ * }
+ *
+ * ... Handle the "related-action" and "use-action-appearance" properties ...
+ *
+ * static void
+ * foo_bar_set_property (GObject *object,
+ * guint prop_id,
+ * const GValue *value,
+ * GParamSpec *pspec)
+ * {
+ * FooBar *bar = FOO_BAR (object);
+ * FooBarPrivate *priv = FOO_BAR_GET_PRIVATE (bar);
+ *
+ * switch (prop_id)
+ * {
+ *
+ * ...
+ *
+ * case PROP_ACTIVATABLE_RELATED_ACTION:
+ * foo_bar_set_related_action (bar, g_value_get_object (value));
+ * break;
+ * case PROP_ACTIVATABLE_USE_ACTION_APPEARANCE:
+ * foo_bar_set_use_action_appearance (bar, g_value_get_boolean (value));
+ * break;
+ * default:
+ * G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ * break;
+ * }
+ * }
+ *
+ * static void
+ * foo_bar_get_property (GObject *object,
+ * guint prop_id,
+ * GValue *value,
+ * GParamSpec *pspec)
+ * {
+ * FooBar *bar = FOO_BAR (object);
+ * FooBarPrivate *priv = FOO_BAR_GET_PRIVATE (bar);
+ *
+ * switch (prop_id)
+ * {
+ *
+ * ...
+ *
+ * case PROP_ACTIVATABLE_RELATED_ACTION:
+ * g_value_set_object (value, priv->action);
+ * break;
+ * case PROP_ACTIVATABLE_USE_ACTION_APPEARANCE:
+ * g_value_set_boolean (value, priv->use_action_appearance);
+ * break;
+ * default:
+ * G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ * break;
+ * }
+ * }
+ *
+ *
+ * static void
+ * foo_bar_set_use_action_appearance (FooBar *bar,
+ * gboolean use_appearance)
+ * {
+ * FooBarPrivate *priv = FOO_BAR_GET_PRIVATE (bar);
+ *
+ * if (priv->use_action_appearance != use_appearance)
+ * {
+ * priv->use_action_appearance = use_appearance;
+ *
+ * gtk_activatable_sync_action_properties (GTK_ACTIVATABLE (bar), priv->action);
+ * }
+ * }
+ *
+ * ... call gtk_activatable_do_set_related_action() and then assign the action pointer,
+ * no need to reference the action here since gtk_activatable_do_set_related_action() already
+ * holds a reference here for you...
+ * static void
+ * foo_bar_set_related_action (FooBar *bar,
+ * GtkAction *action)
+ * {
+ * FooBarPrivate *priv = FOO_BAR_GET_PRIVATE (bar);
+ *
+ * if (priv->action == action)
+ * return;
+ *
+ * gtk_activatable_do_set_related_action (GTK_ACTIVATABLE (bar), action);
+ *
+ * priv->action = action;
+ * }
+ *
+ * ... Selectively reset and update activatable depending on the use-action-appearance property ...
+ * static void
+ * gtk_button_activatable_sync_action_properties (GtkActivatable *activatable,
+ * GtkAction *action)
+ * {
+ * GtkButtonPrivate *priv = GTK_BUTTON_GET_PRIVATE (activatable);
+ *
+ * if (!action)
+ * return;
+ *
+ * if (gtk_action_is_visible (action))
+ * gtk_widget_show (GTK_WIDGET (activatable));
+ * else
+ * gtk_widget_hide (GTK_WIDGET (activatable));
+ *
+ * gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action));
+ *
+ * ...
+ *
+ * if (priv->use_action_appearance)
+ * {
+ * if (gtk_action_get_stock_id (action))
+ * foo_bar_set_stock (button, gtk_action_get_stock_id (action));
+ * else if (gtk_action_get_label (action))
+ * foo_bar_set_label (button, gtk_action_get_label (action));
+ *
+ * ...
+ *
+ * }
+ * }
+ *
+ * static void
+ * foo_bar_activatable_update (GtkActivatable *activatable,
+ * GtkAction *action,
+ * const gchar *property_name)
+ * {
+ * FooBarPrivate *priv = FOO_BAR_GET_PRIVATE (activatable);
+ *
+ * if (strcmp (property_name, "visible") == 0)
+ * {
+ * if (gtk_action_is_visible (action))
+ * gtk_widget_show (GTK_WIDGET (activatable));
+ * else
+ * gtk_widget_hide (GTK_WIDGET (activatable));
+ * }
+ * else if (strcmp (property_name, "sensitive") == 0)
+ * gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action));
+ *
+ * ...
+ *
+ * if (!priv->use_action_appearance)
+ * return;
+ *
+ * if (strcmp (property_name, "stock-id") == 0)
+ * foo_bar_set_stock (button, gtk_action_get_stock_id (action));
+ * else if (strcmp (property_name, "label") == 0)
+ * foo_bar_set_label (button, gtk_action_get_label (action));
+ *
+ * ...
+ * }]]></programlisting>
+ * </example>
+ * </refsect2>
+ */
+
+#include "config.h"
+#define GDK_DISABLE_DEPRECATION_WARNINGS
+#include "gtkactivatable.h"
+#include "gtkactiongroup.h"
+#include "gtkprivate.h"
+#include "gtkintl.h"
+
+
+typedef GtkActivatableIface GtkActivatableInterface;
+G_DEFINE_INTERFACE (GtkActivatable, gtk_activatable, G_TYPE_OBJECT)
+
+static void
+gtk_activatable_default_init (GtkActivatableInterface *iface)
+{
+ /**
+ * GtkActivatable:related-action:
+ *
+ * The action that this activatable will activate and receive
+ * updates from for various states and possibly appearance.
+ *
+ * <note><para>#GtkActivatable implementors need to handle the this property and
+ * call gtk_activatable_do_set_related_action() when it changes.</para></note>
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ */
+ g_object_interface_install_property (iface,
+ g_param_spec_object ("related-action",
+ P_("Related Action"),
+ P_("The action this activatable will activate and receive updates from"),
+ GTK_TYPE_ACTION,
+ GTK_PARAM_READWRITE));
+
+ /**
+ * GtkActivatable:use-action-appearance:
+ *
+ * Whether this activatable should reset its layout
+ * and appearance when setting the related action or when
+ * the action changes appearance.
+ *
+ * See the #GtkAction documentation directly to find which properties
+ * should be ignored by the #GtkActivatable when this property is %FALSE.
+ *
+ * <note><para>#GtkActivatable implementors need to handle this property
+ * and call gtk_activatable_sync_action_properties() on the activatable
+ * widget when it changes.</para></note>
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ */
+ g_object_interface_install_property (iface,
+ g_param_spec_boolean ("use-action-appearance",
+ P_("Use Action Appearance"),
+ P_("Whether to use the related actions appearance properties"),
+ TRUE,
+ GTK_PARAM_READWRITE));
+
+
+}
+
+static void
+gtk_activatable_update (GtkActivatable *activatable,
+ GtkAction *action,
+ const gchar *property_name)
+{
+ GtkActivatableIface *iface;
+
+ g_return_if_fail (GTK_IS_ACTIVATABLE (activatable));
+
+ iface = GTK_ACTIVATABLE_GET_IFACE (activatable);
+ if (iface->update)
+ iface->update (activatable, action, property_name);
+ else
+ g_critical ("GtkActivatable->update() unimplemented for type %s",
+ g_type_name (G_OBJECT_TYPE (activatable)));
+}
+
+/**
+ * gtk_activatable_sync_action_properties:
+ * @activatable: a #GtkActivatable
+ * @action: (allow-none): the related #GtkAction or %NULL
+ *
+ * This is called to update the activatable completely, this is called
+ * internally when the #GtkActivatable:related-action property is set
+ * or unset and by the implementing class when
+ * #GtkActivatable:use-action-appearance changes.
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ **/
+void
+gtk_activatable_sync_action_properties (GtkActivatable *activatable,
+ GtkAction *action)
+{
+ GtkActivatableIface *iface;
+
+ g_return_if_fail (GTK_IS_ACTIVATABLE (activatable));
+
+ iface = GTK_ACTIVATABLE_GET_IFACE (activatable);
+ if (iface->sync_action_properties)
+ iface->sync_action_properties (activatable, action);
+ else
+ g_critical ("GtkActivatable->sync_action_properties() unimplemented for type %s",
+ g_type_name (G_OBJECT_TYPE (activatable)));
+}
+
+
+/**
+ * gtk_activatable_set_related_action:
+ * @activatable: a #GtkActivatable
+ * @action: the #GtkAction to set
+ *
+ * Sets the related action on the @activatable object.
+ *
+ * <note><para>#GtkActivatable implementors need to handle the #GtkActivatable:related-action
+ * property and call gtk_activatable_do_set_related_action() when it changes.</para></note>
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ **/
+void
+gtk_activatable_set_related_action (GtkActivatable *activatable,
+ GtkAction *action)
+{
+ g_return_if_fail (GTK_IS_ACTIVATABLE (activatable));
+ g_return_if_fail (action == NULL || GTK_IS_ACTION (action));
+
+ g_object_set (activatable, "related-action", action, NULL);
+}
+
+static void
+gtk_activatable_action_notify (GtkAction *action,
+ GParamSpec *pspec,
+ GtkActivatable *activatable)
+{
+ gtk_activatable_update (activatable, action, pspec->name);
+}
+
+/**
+ * gtk_activatable_do_set_related_action:
+ * @activatable: a #GtkActivatable
+ * @action: the #GtkAction to set
+ *
+ * This is a utility function for #GtkActivatable implementors.
+ *
+ * When implementing #GtkActivatable you must call this when
+ * handling changes of the #GtkActivatable:related-action, and
+ * you must also use this to break references in #GObject->dispose().
+ *
+ * This function adds a reference to the currently set related
+ * action for you, it also makes sure the #GtkActivatable->update()
+ * method is called when the related #GtkAction properties change
+ * and registers to the action's proxy list.
+ *
+ * <note><para>Be careful to call this before setting the local
+ * copy of the #GtkAction property, since this function uses
+ * gtk_activatable_get_related_action() to retrieve the
+ * previous action</para></note>
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_activatable_do_set_related_action (GtkActivatable *activatable,
+ GtkAction *action)
+{
+ GtkAction *prev_action;
+
+ prev_action = gtk_activatable_get_related_action (activatable);
+
+ if (prev_action != action)
+ {
+ if (prev_action)
+ {
+ g_signal_handlers_disconnect_by_func (prev_action, gtk_activatable_action_notify, activatable);
+
+ /* Check the type so that actions can be activatable too. */
+ if (GTK_IS_WIDGET (activatable))
+ _gtk_action_remove_from_proxy_list (prev_action, GTK_WIDGET (activatable));
+
+ /* Some apps are using the object data directly...
+ * so continue to set it for a bit longer
+ */
+ g_object_set_data (G_OBJECT (activatable), "gtk-action", NULL);
+
+ /*
+ * We don't want prev_action to be activated
+ * during the sync_action_properties() call when syncing "active".
+ */
+ gtk_action_block_activate (prev_action);
+ }
+
+ /* Some applications rely on their proxy UI to be set up
+ * before they receive the ::connect-proxy signal, so we
+ * need to call sync_action_properties() before add_to_proxy_list().
+ */
+ gtk_activatable_sync_action_properties (activatable, action);
+
+ if (prev_action)
+ {
+ gtk_action_unblock_activate (prev_action);
+ g_object_unref (prev_action);
+ }
+
+ if (action)
+ {
+ g_object_ref (action);
+
+ g_signal_connect (G_OBJECT (action), "notify", G_CALLBACK (gtk_activatable_action_notify), activatable);
+
+ if (GTK_IS_WIDGET (activatable))
+ _gtk_action_add_to_proxy_list (action, GTK_WIDGET (activatable));
+
+ g_object_set_data (G_OBJECT (activatable), "gtk-action", action);
+ }
+ }
+}
+
+/**
+ * gtk_activatable_get_related_action:
+ * @activatable: a #GtkActivatable
+ *
+ * Gets the related #GtkAction for @activatable.
+ *
+ * Returns: (transfer none): the related #GtkAction if one is set.
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ **/
+GtkAction *
+gtk_activatable_get_related_action (GtkActivatable *activatable)
+{
+ GtkAction *action;
+
+ g_return_val_if_fail (GTK_IS_ACTIVATABLE (activatable), NULL);
+
+ g_object_get (activatable, "related-action", &action, NULL);
+
+ /* g_object_get() gives us a ref... */
+ if (action)
+ g_object_unref (action);
+
+ return action;
+}
+
+/**
+ * gtk_activatable_set_use_action_appearance:
+ * @activatable: a #GtkActivatable
+ * @use_appearance: whether to use the actions appearance
+ *
+ * Sets whether this activatable should reset its layout and appearance
+ * when setting the related action or when the action changes appearance
+ *
+ * <note><para>#GtkActivatable implementors need to handle the
+ * #GtkActivatable:use-action-appearance property and call
+ * gtk_activatable_sync_action_properties() to update @activatable
+ * if needed.</para></note>
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+**/
+void
+gtk_activatable_set_use_action_appearance (GtkActivatable *activatable,
+ gboolean use_appearance)
+{
+ g_object_set (activatable, "use-action-appearance", use_appearance, NULL);
+}
+
+/**
+ * gtk_activatable_get_use_action_appearance:
+ * @activatable: a #GtkActivatable
+ *
+ * Gets whether this activatable should reset its layout
+ * and appearance when setting the related action or when
+ * the action changes appearance.
+ *
+ * Returns: whether @activatable uses its actions appearance.
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+**/
+gboolean
+gtk_activatable_get_use_action_appearance (GtkActivatable *activatable)
+{
+ gboolean use_appearance;
+
+ g_object_get (activatable, "use-action-appearance", &use_appearance, NULL);
+
+ return use_appearance;
+}
--- /dev/null
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2008 Tristan Van Berkom <tristan.van.berkom@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GTK_ACTIVATABLE_H__
+#define __GTK_ACTIVATABLE_H__
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#include <gtk/deprecated/gtkaction.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_ACTIVATABLE (gtk_activatable_get_type ())
+#define GTK_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ACTIVATABLE, GtkActivatable))
+#define GTK_ACTIVATABLE_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), GTK_TYPE_ACTIVATABLE, GtkActivatableIface))
+#define GTK_IS_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ACTIVATABLE))
+#define GTK_ACTIVATABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_ACTIVATABLE, GtkActivatableIface))
+
+
+typedef struct _GtkActivatable GtkActivatable; /* Dummy typedef */
+typedef struct _GtkActivatableIface GtkActivatableIface;
+
+
+/**
+ * GtkActivatableIface:
+ * @update: Called to update the activatable when its related action's properties change.
+ * You must check the #GtkActivatable:use-action-appearance property only apply action
+ * properties that are meant to effect the appearance accordingly.
+ * @sync_action_properties: Called to update the activatable completely, this is called internally when
+ * #GtkActivatable:related-action property is set or unset and by the implementor when
+ * #GtkActivatable:use-action-appearance changes.<note><para>This method can be called
+ * with a %NULL action at times</para></note>
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10
+ */
+
+struct _GtkActivatableIface
+{
+ GTypeInterface g_iface;
+
+ /* virtual table */
+ void (* update) (GtkActivatable *activatable,
+ GtkAction *action,
+ const gchar *property_name);
+ void (* sync_action_properties) (GtkActivatable *activatable,
+ GtkAction *action);
+};
+
+
+GDK_DEPRECATED_IN_3_10
+GType gtk_activatable_get_type (void) G_GNUC_CONST;
+
+GDK_DEPRECATED_IN_3_10
+void gtk_activatable_sync_action_properties (GtkActivatable *activatable,
+ GtkAction *action);
+
+GDK_DEPRECATED_IN_3_10
+void gtk_activatable_set_related_action (GtkActivatable *activatable,
+ GtkAction *action);
+GDK_DEPRECATED_IN_3_10
+GtkAction *gtk_activatable_get_related_action (GtkActivatable *activatable);
+
+GDK_DEPRECATED_IN_3_10
+void gtk_activatable_set_use_action_appearance (GtkActivatable *activatable,
+ gboolean use_appearance);
+GDK_DEPRECATED_IN_3_10
+gboolean gtk_activatable_get_use_action_appearance (GtkActivatable *activatable);
+
+/* For use in activatable implementations */
+GDK_DEPRECATED_IN_3_10
+void gtk_activatable_do_set_related_action (GtkActivatable *activatable,
+ GtkAction *action);
+
+G_END_DECLS
+
+#endif /* __GTK_ACTIVATABLE_H__ */
--- /dev/null
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2000 Red Hat, Inc.
+ * 2008 Johan Dahlin
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#include "config.h"
+
+#define GDK_DISABLE_DEPRECATION_WARNINGS
+
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+
+#include "gtkiconfactory.h"
+#include "gtkiconcache.h"
+#include "gtkdebug.h"
+#include "gtkicontheme.h"
+#include "gtksettingsprivate.h"
+#include "deprecated/gtkstock.h"
+#include "gtkwidget.h"
+#include "gtkintl.h"
+#include "gtkbuildable.h"
+#include "gtkbuilderprivate.h"
+#include "gtktypebuiltins.h"
+#include "deprecated/gtkstyle.h"
+
+/**
+ * SECTION:gtkiconfactory
+ * @Short_description: Manipulating stock icons
+ * @Title: Themeable Stock Images
+ *
+ * Browse the available stock icons in the list of stock IDs found <link
+ * linkend="gtk-Stock-Items">here</link>. You can also use
+ * the <application>gtk-demo</application> application for this purpose.
+ *
+ * An icon factory manages a collection of #GtkIconSet; a #GtkIconSet manages a
+ * set of variants of a particular icon (i.e. a #GtkIconSet contains variants for
+ * different sizes and widget states). Icons in an icon factory are named by a
+ * stock ID, which is a simple string identifying the icon. Each #GtkStyle has a
+ * list of #GtkIconFactory derived from the current theme; those icon factories
+ * are consulted first when searching for an icon. If the theme doesn't set a
+ * particular icon, GTK+ looks for the icon in a list of default icon factories,
+ * maintained by gtk_icon_factory_add_default() and
+ * gtk_icon_factory_remove_default(). Applications with icons should add a default
+ * icon factory with their icons, which will allow themes to override the icons
+ * for the application.
+ *
+ * To display an icon, always use gtk_style_lookup_icon_set() on the widget that
+ * will display the icon, or the convenience function
+ * gtk_widget_render_icon(). These functions take the theme into account when
+ * looking up the icon to use for a given stock ID.
+ *
+ * <refsect2 id="GtkIconFactory-BUILDER-UI">
+ * <title>GtkIconFactory as GtkBuildable</title>
+ * <para>
+ * GtkIconFactory supports a custom <sources> element, which can contain
+ * multiple <source> elements.
+ * The following attributes are allowed:
+ * <variablelist>
+ * <varlistentry>
+ * <term>stock-id</term>
+ * <listitem><para>
+ * The stock id of the source, a string.
+ * This attribute is mandatory
+ * </para></listitem>
+ * </varlistentry>
+ * <varlistentry>
+ * <term>filename</term>
+ * <listitem><para>
+ * The filename of the source, a string.
+ * This attribute is optional
+ * </para></listitem>
+ * </varlistentry>
+ * <varlistentry>
+ * <term>icon-name</term>
+ * <listitem><para>
+ * The icon name for the source, a string.
+ * This attribute is optional.
+ * </para></listitem>
+ * </varlistentry>
+ * <varlistentry>
+ * <term>size</term>
+ * <listitem><para>
+ * Size of the icon, a #GtkIconSize enum value.
+ * This attribute is optional.
+ * </para></listitem>
+ * </varlistentry>
+ * <varlistentry>
+ * <term>direction</term>
+ * <listitem><para>
+ * Direction of the source, a #GtkTextDirection enum value.
+ * This attribute is optional.
+ * </para></listitem>
+ * </varlistentry>
+ * <varlistentry>
+ * <term>state</term>
+ * <listitem><para>
+ * State of the source, a #GtkStateType enum value.
+ * This attribute is optional.
+ * </para></listitem>
+ * </varlistentry>
+ * </variablelist>
+ * <example>
+ * <title>A #GtkIconFactory UI definition fragment.</title>
+ * <programlisting><![CDATA[
+ * <object class="GtkIconFactory" id="iconfactory1">
+ * <sources>
+ * <source stock-id="apple-red" filename="apple-red.png"/>
+ * </sources>
+ * </object>
+ * <object class="GtkWindow" id="window1">
+ * <child>
+ * <object class="GtkButton" id="apple_button">
+ * <property name="label">apple-red</property>
+ * <property name="use-stock">True</property>
+ * </object>
+ * </child>
+ * </object>
+ * ]]>
+ * </programlisting>
+ * </example>
+ * </para>
+ * </refsect2>
+ */
+
+
+static GSList *all_icon_factories = NULL;
+
+struct _GtkIconFactoryPrivate
+{
+ GHashTable *icons;
+};
+
+typedef enum {
+ GTK_ICON_SOURCE_EMPTY,
+ GTK_ICON_SOURCE_ICON_NAME,
+ GTK_ICON_SOURCE_STATIC_ICON_NAME,
+ GTK_ICON_SOURCE_FILENAME,
+ GTK_ICON_SOURCE_PIXBUF
+} GtkIconSourceType;
+
+struct _GtkIconSource
+{
+ GtkIconSourceType type;
+
+ union {
+ gchar *icon_name;
+ gchar *filename;
+ GdkPixbuf *pixbuf;
+ } source;
+
+ GdkPixbuf *filename_pixbuf;
+
+ GtkTextDirection direction;
+ GtkStateType state;
+ GtkIconSize size;
+
+ /* If TRUE, then the parameter is wildcarded, and the above
+ * fields should be ignored. If FALSE, the parameter is
+ * specified, and the above fields should be valid.
+ */
+ guint any_direction : 1;
+ guint any_state : 1;
+ guint any_size : 1;
+};
+
+
+static void
+gtk_icon_factory_buildable_init (GtkBuildableIface *iface);
+
+static gboolean gtk_icon_factory_buildable_custom_tag_start (GtkBuildable *buildable,
+ GtkBuilder *builder,
+ GObject *child,
+ const gchar *tagname,
+ GMarkupParser *parser,
+ gpointer *data);
+static void gtk_icon_factory_buildable_custom_tag_end (GtkBuildable *buildable,
+ GtkBuilder *builder,
+ GObject *child,
+ const gchar *tagname,
+ gpointer *user_data);
+static void gtk_icon_factory_finalize (GObject *object);
+static void get_default_icons (GtkIconFactory *icon_factory);
+static void icon_source_clear (GtkIconSource *source);
+
+static GtkIconSize icon_size_register_intern (const gchar *name,
+ gint width,
+ gint height);
+
+#define GTK_ICON_SOURCE_INIT(any_direction, any_state, any_size) \
+ { GTK_ICON_SOURCE_EMPTY, { NULL }, NULL, \
+ 0, 0, 0, \
+ any_direction, any_state, any_size }
+
+G_DEFINE_TYPE_WITH_CODE (GtkIconFactory, gtk_icon_factory, G_TYPE_OBJECT,
+ G_ADD_PRIVATE (GtkIconFactory)
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
+ gtk_icon_factory_buildable_init))
+
+static void
+gtk_icon_factory_init (GtkIconFactory *factory)
+{
+ GtkIconFactoryPrivate *priv;
+
+ factory->priv = gtk_icon_factory_get_instance_private (factory);
+ priv = factory->priv;
+
+ priv->icons = g_hash_table_new (g_str_hash, g_str_equal);
+ all_icon_factories = g_slist_prepend (all_icon_factories, factory);
+}
+
+static void
+gtk_icon_factory_class_init (GtkIconFactoryClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gtk_icon_factory_finalize;
+}
+
+static void
+gtk_icon_factory_buildable_init (GtkBuildableIface *iface)
+{
+ iface->custom_tag_start = gtk_icon_factory_buildable_custom_tag_start;
+ iface->custom_tag_end = gtk_icon_factory_buildable_custom_tag_end;
+}
+
+static void
+free_icon_set (gpointer key, gpointer value, gpointer data)
+{
+ g_free (key);
+ gtk_icon_set_unref (value);
+}
+
+static void
+gtk_icon_factory_finalize (GObject *object)
+{
+ GtkIconFactory *factory = GTK_ICON_FACTORY (object);
+ GtkIconFactoryPrivate *priv = factory->priv;
+
+ all_icon_factories = g_slist_remove (all_icon_factories, factory);
+
+ g_hash_table_foreach (priv->icons, free_icon_set, NULL);
+
+ g_hash_table_destroy (priv->icons);
+
+ G_OBJECT_CLASS (gtk_icon_factory_parent_class)->finalize (object);
+}
+
+/**
+ * gtk_icon_factory_new:
+ *
+ * Creates a new #GtkIconFactory. An icon factory manages a collection
+ * of #GtkIconSet<!-- -->s; a #GtkIconSet manages a set of variants of a
+ * particular icon (i.e. a #GtkIconSet contains variants for different
+ * sizes and widget states). Icons in an icon factory are named by a
+ * stock ID, which is a simple string identifying the icon. Each
+ * #GtkStyle has a list of #GtkIconFactory<!-- -->s derived from the current
+ * theme; those icon factories are consulted first when searching for
+ * an icon. If the theme doesn't set a particular icon, GTK+ looks for
+ * the icon in a list of default icon factories, maintained by
+ * gtk_icon_factory_add_default() and
+ * gtk_icon_factory_remove_default(). Applications with icons should
+ * add a default icon factory with their icons, which will allow
+ * themes to override the icons for the application.
+ *
+ * Return value: a new #GtkIconFactory
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+GtkIconFactory*
+gtk_icon_factory_new (void)
+{
+ return g_object_new (GTK_TYPE_ICON_FACTORY, NULL);
+}
+
+/**
+ * gtk_icon_factory_add:
+ * @factory: a #GtkIconFactory
+ * @stock_id: icon name
+ * @icon_set: icon set
+ *
+ * Adds the given @icon_set to the icon factory, under the name
+ * @stock_id. @stock_id should be namespaced for your application,
+ * e.g. "myapp-whatever-icon". Normally applications create a
+ * #GtkIconFactory, then add it to the list of default factories with
+ * gtk_icon_factory_add_default(). Then they pass the @stock_id to
+ * widgets such as #GtkImage to display the icon. Themes can provide
+ * an icon with the same name (such as "myapp-whatever-icon") to
+ * override your application's default icons. If an icon already
+ * existed in @factory for @stock_id, it is unreferenced and replaced
+ * with the new @icon_set.
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+void
+gtk_icon_factory_add (GtkIconFactory *factory,
+ const gchar *stock_id,
+ GtkIconSet *icon_set)
+{
+ GtkIconFactoryPrivate *priv = factory->priv;
+ gpointer old_key = NULL;
+ gpointer old_value = NULL;
+
+ g_return_if_fail (GTK_IS_ICON_FACTORY (factory));
+ g_return_if_fail (stock_id != NULL);
+ g_return_if_fail (icon_set != NULL);
+
+ g_hash_table_lookup_extended (priv->icons, stock_id,
+ &old_key, &old_value);
+
+ if (old_value == icon_set)
+ return;
+
+ gtk_icon_set_ref (icon_set);
+
+ /* GHashTable key memory management is so fantastically broken. */
+ if (old_key)
+ g_hash_table_insert (priv->icons, old_key, icon_set);
+ else
+ g_hash_table_insert (priv->icons, g_strdup (stock_id), icon_set);
+
+ if (old_value)
+ gtk_icon_set_unref (old_value);
+}
+
+/**
+ * gtk_icon_factory_lookup:
+ * @factory: a #GtkIconFactory
+ * @stock_id: an icon name
+ *
+ * Looks up @stock_id in the icon factory, returning an icon set
+ * if found, otherwise %NULL. For display to the user, you should
+ * use gtk_style_lookup_icon_set() on the #GtkStyle for the
+ * widget that will display the icon, instead of using this
+ * function directly, so that themes are taken into account.
+ *
+ * Return value: (transfer none): icon set of @stock_id.
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+GtkIconSet *
+gtk_icon_factory_lookup (GtkIconFactory *factory,
+ const gchar *stock_id)
+{
+ GtkIconFactoryPrivate *priv;
+
+ g_return_val_if_fail (GTK_IS_ICON_FACTORY (factory), NULL);
+ g_return_val_if_fail (stock_id != NULL, NULL);
+
+ priv = factory->priv;
+
+ return g_hash_table_lookup (priv->icons, stock_id);
+}
+
+static GSList *default_factories = NULL;
+
+/**
+ * gtk_icon_factory_add_default:
+ * @factory: a #GtkIconFactory
+ *
+ * Adds an icon factory to the list of icon factories searched by
+ * gtk_style_lookup_icon_set(). This means that, for example,
+ * gtk_image_new_from_stock() will be able to find icons in @factory.
+ * There will normally be an icon factory added for each library or
+ * application that comes with icons. The default icon factories
+ * can be overridden by themes.
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+void
+gtk_icon_factory_add_default (GtkIconFactory *factory)
+{
+ g_return_if_fail (GTK_IS_ICON_FACTORY (factory));
+
+ g_object_ref (factory);
+
+ default_factories = g_slist_prepend (default_factories, factory);
+}
+
+/**
+ * gtk_icon_factory_remove_default:
+ * @factory: a #GtkIconFactory previously added with gtk_icon_factory_add_default()
+ *
+ * Removes an icon factory from the list of default icon
+ * factories. Not normally used; you might use it for a library that
+ * can be unloaded or shut down.
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+void
+gtk_icon_factory_remove_default (GtkIconFactory *factory)
+{
+ g_return_if_fail (GTK_IS_ICON_FACTORY (factory));
+
+ default_factories = g_slist_remove (default_factories, factory);
+
+ g_object_unref (factory);
+}
+
+static GtkIconFactory *
+_gtk_icon_factory_get_default_icons (void)
+{
+ static GtkIconFactory *default_icons = NULL;
+ GtkIconFactory *icons = NULL;
+ GdkScreen *screen = gdk_screen_get_default ();
+
+ if (screen)
+ icons = g_object_get_data (G_OBJECT (screen), "gtk-default-icons");
+
+ if (icons == NULL)
+ {
+ if (default_icons == NULL)
+ {
+ default_icons = gtk_icon_factory_new ();
+ get_default_icons (default_icons);
+ }
+ if (screen)
+ g_object_set_data_full (G_OBJECT (screen),
+ I_("gtk-default-icons"),
+ default_icons,
+ g_object_unref);
+ icons = default_icons;
+ }
+
+ return icons;
+}
+
+/**
+ * gtk_icon_factory_lookup_default:
+ * @stock_id: an icon name
+ *
+ * Looks for an icon in the list of default icon factories. For
+ * display to the user, you should use gtk_style_lookup_icon_set() on
+ * the #GtkStyle for the widget that will display the icon, instead of
+ * using this function directly, so that themes are taken into
+ * account.
+ *
+ * Return value: (transfer none): a #GtkIconSet, or %NULL
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+GtkIconSet *
+gtk_icon_factory_lookup_default (const gchar *stock_id)
+{
+ GSList *tmp_list;
+ GtkIconFactory *default_icons;
+
+ g_return_val_if_fail (stock_id != NULL, NULL);
+
+ tmp_list = default_factories;
+ while (tmp_list != NULL)
+ {
+ GtkIconSet *icon_set =
+ gtk_icon_factory_lookup (GTK_ICON_FACTORY (tmp_list->data),
+ stock_id);
+
+ if (icon_set)
+ return icon_set;
+
+ tmp_list = g_slist_next (tmp_list);
+ }
+
+ default_icons = _gtk_icon_factory_get_default_icons ();
+ if (default_icons)
+ return gtk_icon_factory_lookup (default_icons, stock_id);
+ else
+ return NULL;
+}
+
+static void
+register_stock_icon (GtkIconFactory *factory,
+ const gchar *stock_id,
+ const gchar *icon_name)
+{
+ GtkIconSet *set = gtk_icon_set_new ();
+ GtkIconSource source = GTK_ICON_SOURCE_INIT (TRUE, TRUE, TRUE);
+
+ source.type = GTK_ICON_SOURCE_STATIC_ICON_NAME;
+ source.source.icon_name = (gchar *)icon_name;
+ source.direction = GTK_TEXT_DIR_NONE;
+ gtk_icon_set_add_source (set, &source);
+
+ gtk_icon_factory_add (factory, stock_id, set);
+ gtk_icon_set_unref (set);
+}
+
+static void
+register_bidi_stock_icon (GtkIconFactory *factory,
+ const gchar *stock_id,
+ const gchar *icon_name)
+{
+ GtkIconSet *set = gtk_icon_set_new ();
+ GtkIconSource source = GTK_ICON_SOURCE_INIT (FALSE, TRUE, TRUE);
+
+ source.type = GTK_ICON_SOURCE_STATIC_ICON_NAME;
+ source.source.icon_name = (gchar *)icon_name;
+ source.direction = GTK_TEXT_DIR_LTR;
+ gtk_icon_set_add_source (set, &source);
+
+ source.type = GTK_ICON_SOURCE_STATIC_ICON_NAME;
+ source.source.icon_name = (gchar *)icon_name;
+ source.direction = GTK_TEXT_DIR_RTL;
+ gtk_icon_set_add_source (set, &source);
+
+ gtk_icon_factory_add (factory, stock_id, set);
+ gtk_icon_set_unref (set);
+}
+
+static void
+get_default_icons (GtkIconFactory *factory)
+{
+ /* KEEP IN SYNC with gtkstock.c */
+
+ register_stock_icon (factory, GTK_STOCK_DIALOG_AUTHENTICATION, "dialog-password");
+ register_stock_icon (factory, GTK_STOCK_DIALOG_ERROR, "dialog-error");
+ register_stock_icon (factory, GTK_STOCK_DIALOG_INFO, "dialog-information");
+ register_stock_icon (factory, GTK_STOCK_DIALOG_QUESTION, "dialog-question");
+ register_stock_icon (factory, GTK_STOCK_DIALOG_WARNING, "dialog-warning");
+ register_stock_icon (factory, GTK_STOCK_DND, GTK_STOCK_DND);
+ register_stock_icon (factory, GTK_STOCK_DND_MULTIPLE, GTK_STOCK_DND_MULTIPLE);
+ register_stock_icon (factory, GTK_STOCK_APPLY, GTK_STOCK_APPLY);
+ register_stock_icon (factory, GTK_STOCK_CANCEL, GTK_STOCK_CANCEL);
+ register_stock_icon (factory, GTK_STOCK_NO, GTK_STOCK_NO);
+ register_stock_icon (factory, GTK_STOCK_OK, GTK_STOCK_OK);
+ register_stock_icon (factory, GTK_STOCK_YES, GTK_STOCK_YES);
+ register_stock_icon (factory, GTK_STOCK_CLOSE, "window-close");
+ register_stock_icon (factory, GTK_STOCK_ADD, "list-add");
+ register_stock_icon (factory, GTK_STOCK_JUSTIFY_CENTER, "format-justify-center");
+ register_stock_icon (factory, GTK_STOCK_JUSTIFY_FILL, "format-justify-fill");
+ register_stock_icon (factory, GTK_STOCK_JUSTIFY_LEFT, "format-justify-left");
+ register_stock_icon (factory, GTK_STOCK_JUSTIFY_RIGHT, "format-justify-right");
+ register_stock_icon (factory, GTK_STOCK_GOTO_BOTTOM, "go-bottom");
+ register_stock_icon (factory, GTK_STOCK_CDROM, "media-optical");
+ register_stock_icon (factory, GTK_STOCK_CONVERT, GTK_STOCK_CONVERT);
+ register_stock_icon (factory, GTK_STOCK_COPY, "edit-copy");
+ register_stock_icon (factory, GTK_STOCK_CUT, "edit-cut");
+ register_stock_icon (factory, GTK_STOCK_GO_DOWN, "go-down");
+ register_stock_icon (factory, GTK_STOCK_EXECUTE, "system-run");
+ register_stock_icon (factory, GTK_STOCK_QUIT, "application-exit");
+ register_bidi_stock_icon (factory, GTK_STOCK_GOTO_FIRST, "go-first");
+ register_stock_icon (factory, GTK_STOCK_SELECT_FONT, GTK_STOCK_SELECT_FONT);
+ register_stock_icon (factory, GTK_STOCK_FULLSCREEN, "view-fullscreen");
+ register_stock_icon (factory, GTK_STOCK_LEAVE_FULLSCREEN, "view-restore");
+ register_stock_icon (factory, GTK_STOCK_HARDDISK, "drive-harddisk");
+ register_stock_icon (factory, GTK_STOCK_HELP, "help-contents");
+ register_stock_icon (factory, GTK_STOCK_HOME, "go-home");
+ register_stock_icon (factory, GTK_STOCK_INFO, "dialog-information");
+ register_bidi_stock_icon (factory, GTK_STOCK_JUMP_TO, "go-jump");
+ register_bidi_stock_icon (factory, GTK_STOCK_GOTO_LAST, "go-last");
+ register_bidi_stock_icon (factory, GTK_STOCK_GO_BACK, "go-previous");
+ register_stock_icon (factory, GTK_STOCK_MISSING_IMAGE, "image-missing");
+ register_stock_icon (factory, GTK_STOCK_NETWORK, "network-idle");
+ register_stock_icon (factory, GTK_STOCK_NEW, "document-new");
+ register_stock_icon (factory, GTK_STOCK_OPEN, "document-open");
+ register_stock_icon (factory, GTK_STOCK_ORIENTATION_PORTRAIT, GTK_STOCK_ORIENTATION_PORTRAIT);
+ register_stock_icon (factory, GTK_STOCK_ORIENTATION_LANDSCAPE, GTK_STOCK_ORIENTATION_LANDSCAPE);
+ register_stock_icon (factory, GTK_STOCK_ORIENTATION_REVERSE_PORTRAIT, GTK_STOCK_ORIENTATION_REVERSE_PORTRAIT);
+ register_stock_icon (factory, GTK_STOCK_ORIENTATION_REVERSE_LANDSCAPE, GTK_STOCK_ORIENTATION_REVERSE_LANDSCAPE);
+ register_stock_icon (factory, GTK_STOCK_PAGE_SETUP, GTK_STOCK_PAGE_SETUP);
+ register_stock_icon (factory, GTK_STOCK_PASTE, "edit-paste");
+ register_stock_icon (factory, GTK_STOCK_PREFERENCES, GTK_STOCK_PREFERENCES);
+ register_stock_icon (factory, GTK_STOCK_PRINT, "document-print");
+ register_stock_icon (factory, GTK_STOCK_PRINT_ERROR, "printer-error");
+ register_stock_icon (factory, GTK_STOCK_PRINT_PAUSED, "printer-paused");
+ register_stock_icon (factory, GTK_STOCK_PRINT_PREVIEW, "document-print-preview");
+ register_stock_icon (factory, GTK_STOCK_PRINT_REPORT, "printer-info");
+ register_stock_icon (factory, GTK_STOCK_PRINT_WARNING, "printer-warning");
+ register_stock_icon (factory, GTK_STOCK_PROPERTIES, "document-properties");
+ register_bidi_stock_icon (factory, GTK_STOCK_REDO, "edit-redo");
+ register_stock_icon (factory, GTK_STOCK_REMOVE, "list-remove");
+ register_stock_icon (factory, GTK_STOCK_REFRESH, "view-refresh");
+ register_bidi_stock_icon (factory, GTK_STOCK_REVERT_TO_SAVED, "document-revert");
+ register_bidi_stock_icon (factory, GTK_STOCK_GO_FORWARD, "go-next");
+ register_stock_icon (factory, GTK_STOCK_SAVE, "document-save");
+ register_stock_icon (factory, GTK_STOCK_FLOPPY, "media-floppy");
+ register_stock_icon (factory, GTK_STOCK_SAVE_AS, "document-save-as");
+ register_stock_icon (factory, GTK_STOCK_FIND, "edit-find");
+ register_stock_icon (factory, GTK_STOCK_FIND_AND_REPLACE, "edit-find-replace");
+ register_stock_icon (factory, GTK_STOCK_SORT_DESCENDING, "view-sort-descending");
+ register_stock_icon (factory, GTK_STOCK_SORT_ASCENDING, "view-sort-ascending");
+ register_stock_icon (factory, GTK_STOCK_SPELL_CHECK, "tools-check-spelling");
+ register_stock_icon (factory, GTK_STOCK_STOP, "process-stop");
+ register_stock_icon (factory, GTK_STOCK_BOLD, "format-text-bold");
+ register_stock_icon (factory, GTK_STOCK_ITALIC, "format-text-italic");
+ register_stock_icon (factory, GTK_STOCK_STRIKETHROUGH, "format-text-strikethrough");
+ register_stock_icon (factory, GTK_STOCK_UNDERLINE, "format-text-underline");
+ register_bidi_stock_icon (factory, GTK_STOCK_INDENT, "format-indent-more");
+ register_bidi_stock_icon (factory, GTK_STOCK_UNINDENT, "format-indent-less");
+ register_stock_icon (factory, GTK_STOCK_GOTO_TOP, "go-top");
+ register_stock_icon (factory, GTK_STOCK_DELETE, "edit-delete");
+ register_bidi_stock_icon (factory, GTK_STOCK_UNDELETE, GTK_STOCK_UNDELETE);
+ register_bidi_stock_icon (factory, GTK_STOCK_UNDO, "edit-undo");
+ register_stock_icon (factory, GTK_STOCK_GO_UP, "go-up");
+ register_stock_icon (factory, GTK_STOCK_FILE, "text-x-generic");
+ register_stock_icon (factory, GTK_STOCK_DIRECTORY, "folder");
+ register_stock_icon (factory, GTK_STOCK_ABOUT, "help-about");
+ register_stock_icon (factory, GTK_STOCK_CONNECT, GTK_STOCK_CONNECT);
+ register_stock_icon (factory, GTK_STOCK_DISCONNECT, GTK_STOCK_DISCONNECT);
+ register_stock_icon (factory, GTK_STOCK_EDIT, GTK_STOCK_EDIT);
+ register_stock_icon (factory, GTK_STOCK_CAPS_LOCK_WARNING, GTK_STOCK_CAPS_LOCK_WARNING);
+ register_bidi_stock_icon (factory, GTK_STOCK_MEDIA_FORWARD, "media-seek-forward");
+ register_bidi_stock_icon (factory, GTK_STOCK_MEDIA_NEXT, "media-skip-forward");
+ register_stock_icon (factory, GTK_STOCK_MEDIA_PAUSE, "media-playback-pause");
+ register_bidi_stock_icon (factory, GTK_STOCK_MEDIA_PLAY, "media-playback-start");
+ register_bidi_stock_icon (factory, GTK_STOCK_MEDIA_PREVIOUS, "media-skip-backward");
+ register_stock_icon (factory, GTK_STOCK_MEDIA_RECORD, "media-record");
+ register_bidi_stock_icon (factory, GTK_STOCK_MEDIA_REWIND, "media-seek-backward");
+ register_stock_icon (factory, GTK_STOCK_MEDIA_STOP, "media-playback-stop");
+ register_stock_icon (factory, GTK_STOCK_INDEX, GTK_STOCK_INDEX);
+ register_stock_icon (factory, GTK_STOCK_ZOOM_100, "zoom-original");
+ register_stock_icon (factory, GTK_STOCK_ZOOM_IN, "zoom-in");
+ register_stock_icon (factory, GTK_STOCK_ZOOM_OUT, "zoom-out");
+ register_stock_icon (factory, GTK_STOCK_ZOOM_FIT, "zoom-fit-best");
+ register_stock_icon (factory, GTK_STOCK_SELECT_ALL, "edit-select-all");
+ register_stock_icon (factory, GTK_STOCK_CLEAR, "edit-clear");
+ register_stock_icon (factory, GTK_STOCK_SELECT_COLOR, GTK_STOCK_SELECT_COLOR);
+ register_stock_icon (factory, GTK_STOCK_COLOR_PICKER, GTK_STOCK_COLOR_PICKER);
+}
+
+/************************************************************
+ * Icon size handling *
+ ************************************************************/
+
+typedef struct _IconSize IconSize;
+
+struct _IconSize
+{
+ gint size;
+ gchar *name;
+
+ gint width;
+ gint height;
+};
+
+typedef struct _IconAlias IconAlias;
+
+struct _IconAlias
+{
+ gchar *name;
+ gint target;
+};
+
+static GHashTable *icon_aliases = NULL;
+static IconSize *icon_sizes = NULL;
+static gint icon_sizes_allocated = 0;
+static gint icon_sizes_used = 0;
+
+static void
+init_icon_sizes (void)
+{
+ if (icon_sizes == NULL)
+ {
+#define NUM_BUILTIN_SIZES 7
+ gint i;
+
+ icon_aliases = g_hash_table_new (g_str_hash, g_str_equal);
+
+ icon_sizes = g_new (IconSize, NUM_BUILTIN_SIZES);
+ icon_sizes_allocated = NUM_BUILTIN_SIZES;
+ icon_sizes_used = NUM_BUILTIN_SIZES;
+
+ icon_sizes[GTK_ICON_SIZE_INVALID].size = 0;
+ icon_sizes[GTK_ICON_SIZE_INVALID].name = NULL;
+ icon_sizes[GTK_ICON_SIZE_INVALID].width = 0;
+ icon_sizes[GTK_ICON_SIZE_INVALID].height = 0;
+
+ /* the name strings aren't copied since we don't ever remove
+ * icon sizes, so we don't need to know whether they're static.
+ * Even if we did I suppose removing the builtin sizes would be
+ * disallowed.
+ */
+
+ icon_sizes[GTK_ICON_SIZE_MENU].size = GTK_ICON_SIZE_MENU;
+ icon_sizes[GTK_ICON_SIZE_MENU].name = "gtk-menu";
+ icon_sizes[GTK_ICON_SIZE_MENU].width = 16;
+ icon_sizes[GTK_ICON_SIZE_MENU].height = 16;
+
+ icon_sizes[GTK_ICON_SIZE_BUTTON].size = GTK_ICON_SIZE_BUTTON;
+ icon_sizes[GTK_ICON_SIZE_BUTTON].name = "gtk-button";
+ icon_sizes[GTK_ICON_SIZE_BUTTON].width = 20;
+ icon_sizes[GTK_ICON_SIZE_BUTTON].height = 20;
+
+ icon_sizes[GTK_ICON_SIZE_SMALL_TOOLBAR].size = GTK_ICON_SIZE_SMALL_TOOLBAR;
+ icon_sizes[GTK_ICON_SIZE_SMALL_TOOLBAR].name = "gtk-small-toolbar";
+ icon_sizes[GTK_ICON_SIZE_SMALL_TOOLBAR].width = 18;
+ icon_sizes[GTK_ICON_SIZE_SMALL_TOOLBAR].height = 18;
+
+ icon_sizes[GTK_ICON_SIZE_LARGE_TOOLBAR].size = GTK_ICON_SIZE_LARGE_TOOLBAR;
+ icon_sizes[GTK_ICON_SIZE_LARGE_TOOLBAR].name = "gtk-large-toolbar";
+ icon_sizes[GTK_ICON_SIZE_LARGE_TOOLBAR].width = 24;
+ icon_sizes[GTK_ICON_SIZE_LARGE_TOOLBAR].height = 24;
+
+ icon_sizes[GTK_ICON_SIZE_DND].size = GTK_ICON_SIZE_DND;
+ icon_sizes[GTK_ICON_SIZE_DND].name = "gtk-dnd";
+ icon_sizes[GTK_ICON_SIZE_DND].width = 32;
+ icon_sizes[GTK_ICON_SIZE_DND].height = 32;
+
+ icon_sizes[GTK_ICON_SIZE_DIALOG].size = GTK_ICON_SIZE_DIALOG;
+ icon_sizes[GTK_ICON_SIZE_DIALOG].name = "gtk-dialog";
+ icon_sizes[GTK_ICON_SIZE_DIALOG].width = 48;
+ icon_sizes[GTK_ICON_SIZE_DIALOG].height = 48;
+
+ g_assert ((GTK_ICON_SIZE_DIALOG + 1) == NUM_BUILTIN_SIZES);
+
+ /* Alias everything to itself. */
+ i = 1; /* skip invalid size */
+ while (i < NUM_BUILTIN_SIZES)
+ {
+ gtk_icon_size_register_alias (icon_sizes[i].name, icon_sizes[i].size);
+
+ ++i;
+ }
+
+#undef NUM_BUILTIN_SIZES
+ }
+}
+
+static gboolean
+icon_size_lookup_intern (GtkIconSize size,
+ gint *widthp,
+ gint *heightp)
+{
+ init_icon_sizes ();
+
+ if (size == (GtkIconSize)-1)
+ return FALSE;
+
+ if (size >= icon_sizes_used)
+ return FALSE;
+
+ if (size == GTK_ICON_SIZE_INVALID)
+ return FALSE;
+
+ if (widthp)
+ *widthp = icon_sizes[size].width;
+
+ if (heightp)
+ *heightp = icon_sizes[size].height;
+
+ return TRUE;
+}
+
+/**
+ * gtk_icon_size_lookup_for_settings:
+ * @settings: a #GtkSettings object, used to determine
+ * which set of user preferences to used.
+ * @size: (type int): an icon size
+ * @width: (out) (allow-none): location to store icon width
+ * @height: (out) (allow-none): location to store icon height
+ *
+ * Obtains the pixel size of a semantic icon size, possibly
+ * modified by user preferences for a particular
+ * #GtkSettings. Normally @size would be
+ * #GTK_ICON_SIZE_MENU, #GTK_ICON_SIZE_BUTTON, etc. This function
+ * isn't normally needed, gtk_widget_render_icon_pixbuf() is the usual
+ * way to get an icon for rendering, then just look at the size of
+ * the rendered pixbuf. The rendered pixbuf may not even correspond to
+ * the width/height returned by gtk_icon_size_lookup(), because themes
+ * are free to render the pixbuf however they like, including changing
+ * the usual size.
+ *
+ * Return value: %TRUE if @size was a valid size
+ *
+ * Since: 2.2
+ *
+ * Deprecated: 3.10: Use gtk_icon_size_lookup() instead.
+ */
+gboolean
+gtk_icon_size_lookup_for_settings (GtkSettings *settings,
+ GtkIconSize size,
+ gint *width,
+ gint *height)
+{
+ g_return_val_if_fail (GTK_IS_SETTINGS (settings), FALSE);
+
+ return icon_size_lookup_intern (size, width, height);
+}
+
+/**
+ * gtk_icon_size_lookup:
+ * @size: (type int): an icon size
+ * @width: (out) (allow-none): location to store icon width
+ * @height: (out) (allow-none): location to store icon height
+ *
+ * Obtains the pixel size of a semantic icon size @size:
+ * #GTK_ICON_SIZE_MENU, #GTK_ICON_SIZE_BUTTON, etc. This function
+ * isn't normally needed, gtk_icon_theme_load_icon() is the usual
+ * way to get an icon for rendering, then just look at the size of
+ * the rendered pixbuf. The rendered pixbuf may not even correspond to
+ * the width/height returned by gtk_icon_size_lookup(), because themes
+ * are free to render the pixbuf however they like, including changing
+ * the usual size.
+ *
+ * Return value: %TRUE if @size was a valid size
+ */
+gboolean
+gtk_icon_size_lookup (GtkIconSize size,
+ gint *widthp,
+ gint *heightp)
+{
+ GTK_NOTE (MULTIHEAD,
+ g_warning ("gtk_icon_size_lookup ()) is not multihead safe"));
+
+ return icon_size_lookup_intern (size, widthp, heightp);
+}
+
+static GtkIconSize
+icon_size_register_intern (const gchar *name,
+ gint width,
+ gint height)
+{
+ IconAlias *old_alias;
+ GtkIconSize size;
+
+ init_icon_sizes ();
+
+ old_alias = g_hash_table_lookup (icon_aliases, name);
+ if (old_alias && icon_sizes[old_alias->target].width > 0)
+ {
+ g_warning ("Icon size name '%s' already exists", name);
+ return GTK_ICON_SIZE_INVALID;
+ }
+
+ if (old_alias)
+ {
+ size = old_alias->target;
+ }
+ else
+ {
+ if (icon_sizes_used == icon_sizes_allocated)
+ {
+ icon_sizes_allocated *= 2;
+ icon_sizes = g_renew (IconSize, icon_sizes, icon_sizes_allocated);
+ }
+
+ size = icon_sizes_used++;
+
+ /* alias to self. */
+ gtk_icon_size_register_alias (name, size);
+
+ icon_sizes[size].size = size;
+ icon_sizes[size].name = g_strdup (name);
+ }
+
+ icon_sizes[size].width = width;
+ icon_sizes[size].height = height;
+
+ return size;
+}
+
+/**
+ * gtk_icon_size_register:
+ * @name: name of the icon size
+ * @width: the icon width
+ * @height: the icon height
+ *
+ * Registers a new icon size, along the same lines as #GTK_ICON_SIZE_MENU,
+ * etc. Returns the integer value for the size.
+ *
+ * Returns: (type int): integer value representing the size
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+GtkIconSize
+gtk_icon_size_register (const gchar *name,
+ gint width,
+ gint height)
+{
+ g_return_val_if_fail (name != NULL, 0);
+ g_return_val_if_fail (width > 0, 0);
+ g_return_val_if_fail (height > 0, 0);
+
+ return icon_size_register_intern (name, width, height);
+}
+
+/**
+ * gtk_icon_size_register_alias:
+ * @alias: an alias for @target
+ * @target: (type int): an existing icon size
+ *
+ * Registers @alias as another name for @target.
+ * So calling gtk_icon_size_from_name() with @alias as argument
+ * will return @target.
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+void
+gtk_icon_size_register_alias (const gchar *alias,
+ GtkIconSize target)
+{
+ IconAlias *ia;
+
+ g_return_if_fail (alias != NULL);
+
+ init_icon_sizes ();
+
+ if (!icon_size_lookup_intern (target, NULL, NULL))
+ g_warning ("gtk_icon_size_register_alias: Icon size %u does not exist", target);
+
+ ia = g_hash_table_lookup (icon_aliases, alias);
+ if (ia)
+ {
+ if (icon_sizes[ia->target].width > 0)
+ {
+ g_warning ("gtk_icon_size_register_alias: Icon size name '%s' already exists", alias);
+ return;
+ }
+
+ ia->target = target;
+ }
+
+ if (!ia)
+ {
+ ia = g_new (IconAlias, 1);
+ ia->name = g_strdup (alias);
+ ia->target = target;
+
+ g_hash_table_insert (icon_aliases, ia->name, ia);
+ }
+}
+
+/**
+ * gtk_icon_size_from_name:
+ * @name: the name to look up.
+ *
+ * Looks up the icon size associated with @name.
+ *
+ * Return value: (type int): the icon size
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+GtkIconSize
+gtk_icon_size_from_name (const gchar *name)
+{
+ IconAlias *ia;
+
+ init_icon_sizes ();
+
+ ia = g_hash_table_lookup (icon_aliases, name);
+
+ if (ia && icon_sizes[ia->target].width > 0)
+ return ia->target;
+ else
+ return GTK_ICON_SIZE_INVALID;
+}
+
+/**
+ * gtk_icon_size_get_name:
+ * @size: (type int): a #GtkIconSize.
+ *
+ * Gets the canonical name of the given icon size. The returned string
+ * is statically allocated and should not be freed.
+ *
+ * Returns: the name of the given icon size.
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+const gchar*
+gtk_icon_size_get_name (GtkIconSize size)
+{
+ if (size >= icon_sizes_used)
+ return NULL;
+ else
+ return icon_sizes[size].name;
+}
+
+/************************************************************/
+
+/* Icon Set */
+
+
+static GdkPixbuf *find_in_cache (GtkIconSet *icon_set,
+ GtkStyleContext *style_context,
+ GtkTextDirection direction,
+ GtkStateType state,
+ GtkIconSize size,
+ gint scale);
+static void add_to_cache (GtkIconSet *icon_set,
+ GtkStyleContext *style_context,
+ GtkTextDirection direction,
+ GtkStateType state,
+ GtkIconSize size,
+ gint scale,
+ GdkPixbuf *pixbuf);
+/* Clear icon set contents, drop references to all contained
+ * GdkPixbuf objects and forget all GtkIconSources. Used to
+ * recycle an icon set.
+ */
+static void clear_cache (GtkIconSet *icon_set,
+ gboolean style_detach);
+static GSList* copy_cache (GtkIconSet *icon_set,
+ GtkIconSet *copy_recipient);
+static void attach_to_style (GtkIconSet *icon_set,
+ GtkStyleContext *style_context);
+static void detach_from_style (GtkIconSet *icon_set,
+ GtkStyleContext *style_context);
+static void style_dnotify (gpointer data);
+
+struct _GtkIconSet
+{
+ guint ref_count;
+
+ GSList *sources;
+
+ /* Cache of the last few rendered versions of the icon. */
+ GSList *cache;
+
+ guint cache_size;
+
+ guint cache_serial;
+};
+
+static guint cache_serial = 0;
+
+/**
+ * gtk_icon_set_new:
+ *
+ * Creates a new #GtkIconSet. A #GtkIconSet represents a single icon
+ * in various sizes and widget states. It can provide a #GdkPixbuf
+ * for a given size and state on request, and automatically caches
+ * some of the rendered #GdkPixbuf objects.
+ *
+ * Normally you would use gtk_widget_render_icon_pixbuf() instead of
+ * using #GtkIconSet directly. The one case where you'd use
+ * #GtkIconSet is to create application-specific icon sets to place in
+ * a #GtkIconFactory.
+ *
+ * Return value: a new #GtkIconSet
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+GtkIconSet*
+gtk_icon_set_new (void)
+{
+ GtkIconSet *icon_set;
+
+ icon_set = g_new (GtkIconSet, 1);
+
+ icon_set->ref_count = 1;
+ icon_set->sources = NULL;
+ icon_set->cache = NULL;
+ icon_set->cache_size = 0;
+ icon_set->cache_serial = cache_serial;
+
+ return icon_set;
+}
+
+/**
+ * gtk_icon_set_new_from_pixbuf:
+ * @pixbuf: a #GdkPixbuf
+ *
+ * Creates a new #GtkIconSet with @pixbuf as the default/fallback
+ * source image. If you don't add any additional #GtkIconSource to the
+ * icon set, all variants of the icon will be created from @pixbuf,
+ * using scaling, pixelation, etc. as required to adjust the icon size
+ * or make the icon look insensitive/prelighted.
+ *
+ * Return value: a new #GtkIconSet
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+GtkIconSet *
+gtk_icon_set_new_from_pixbuf (GdkPixbuf *pixbuf)
+{
+ GtkIconSet *set;
+
+ GtkIconSource source = GTK_ICON_SOURCE_INIT (TRUE, TRUE, TRUE);
+
+ g_return_val_if_fail (pixbuf != NULL, NULL);
+
+ set = gtk_icon_set_new ();
+
+ gtk_icon_source_set_pixbuf (&source, pixbuf);
+ gtk_icon_set_add_source (set, &source);
+ gtk_icon_source_set_pixbuf (&source, NULL);
+
+ return set;
+}
+
+
+/**
+ * gtk_icon_set_ref:
+ * @icon_set: a #GtkIconSet.
+ *
+ * Increments the reference count on @icon_set.
+ *
+ * Return value: @icon_set.
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+GtkIconSet*
+gtk_icon_set_ref (GtkIconSet *icon_set)
+{
+ g_return_val_if_fail (icon_set != NULL, NULL);
+ g_return_val_if_fail (icon_set->ref_count > 0, NULL);
+
+ icon_set->ref_count += 1;
+
+ return icon_set;
+}
+
+/**
+ * gtk_icon_set_unref:
+ * @icon_set: a #GtkIconSet
+ *
+ * Decrements the reference count on @icon_set, and frees memory
+ * if the reference count reaches 0.
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+void
+gtk_icon_set_unref (GtkIconSet *icon_set)
+{
+ g_return_if_fail (icon_set != NULL);
+ g_return_if_fail (icon_set->ref_count > 0);
+
+ icon_set->ref_count -= 1;
+
+ if (icon_set->ref_count == 0)
+ {
+ GSList *tmp_list = icon_set->sources;
+ while (tmp_list != NULL)
+ {
+ gtk_icon_source_free (tmp_list->data);
+
+ tmp_list = g_slist_next (tmp_list);
+ }
+ g_slist_free (icon_set->sources);
+
+ clear_cache (icon_set, TRUE);
+
+ g_free (icon_set);
+ }
+}
+
+G_DEFINE_BOXED_TYPE (GtkIconSet, gtk_icon_set,
+ gtk_icon_set_ref,
+ gtk_icon_set_unref)
+
+/**
+ * gtk_icon_set_copy:
+ * @icon_set: a #GtkIconSet
+ *
+ * Copies @icon_set by value.
+ *
+ * Return value: a new #GtkIconSet identical to the first.
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ **/
+GtkIconSet*
+gtk_icon_set_copy (GtkIconSet *icon_set)
+{
+ GtkIconSet *copy;
+ GSList *tmp_list;
+
+ copy = gtk_icon_set_new ();
+
+ tmp_list = icon_set->sources;
+ while (tmp_list != NULL)
+ {
+ copy->sources = g_slist_prepend (copy->sources,
+ gtk_icon_source_copy (tmp_list->data));
+
+ tmp_list = g_slist_next (tmp_list);
+ }
+
+ copy->sources = g_slist_reverse (copy->sources);
+
+ copy->cache = copy_cache (icon_set, copy);
+ copy->cache_size = icon_set->cache_size;
+ copy->cache_serial = icon_set->cache_serial;
+
+ return copy;
+}
+
+static gboolean
+sizes_equivalent (GtkIconSize lhs,
+ GtkIconSize rhs)
+{
+ /* We used to consider sizes equivalent if they were
+ * the same pixel size, but we don't have the GtkSettings
+ * here, so we can't do that. Plus, it's not clear that
+ * it is right... it was just a workaround for the fact
+ * that we register icons by logical size, not pixel size.
+ */
+#if 1
+ return lhs == rhs;
+#else
+
+ gint r_w, r_h, l_w, l_h;
+
+ icon_size_lookup_intern (rhs, &r_w, &r_h);
+ icon_size_lookup_intern (lhs, &l_w, &l_h);
+
+ return r_w == l_w && r_h == l_h;
+#endif
+}
+
+static GtkIconSource *
+find_best_matching_source (GtkIconSet *icon_set,
+ GtkTextDirection direction,
+ GtkStateType state,
+ GtkIconSize size,
+ GSList *failed)
+{
+ GtkIconSource *source;
+ GSList *tmp_list;
+
+ /* We need to find the best icon source. Direction matters more
+ * than state, state matters more than size. icon_set->sources
+ * is sorted according to wildness, so if we take the first
+ * match we find it will be the least-wild match (if there are
+ * multiple matches for a given "wildness" then the RC file contained
+ * dumb stuff, and we end up with an arbitrary matching source)
+ */
+
+ source = NULL;
+ tmp_list = icon_set->sources;
+ while (tmp_list != NULL)
+ {
+ GtkIconSource *s = tmp_list->data;
+
+ if ((s->any_direction || (s->direction == direction)) &&
+ (s->any_state || (s->state == state)) &&
+ (s->any_size || size == (GtkIconSize)-1 || (sizes_equivalent (size, s->size))))
+ {
+ if (!g_slist_find (failed, s))
+ {
+ source = s;
+ break;
+ }
+ }
+
+ tmp_list = g_slist_next (tmp_list);
+ }
+
+ return source;
+}
+
+static gboolean
+ensure_filename_pixbuf (GtkIconSet *icon_set,
+ GtkIconSource *source)
+{
+ if (source->filename_pixbuf == NULL)
+ {
+ GError *error = NULL;
+
+ source->filename_pixbuf = gdk_pixbuf_new_from_file (source->source.filename, &error);
+
+ if (source->filename_pixbuf == NULL)
+ {
+ /* Remove this icon source so we don't keep trying to
+ * load it.
+ */
+ g_warning ("Error loading icon: %s", error->message);
+ g_error_free (error);
+
+ icon_set->sources = g_slist_remove (icon_set->sources, source);
+
+ gtk_icon_source_free (source);
+
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+static GdkPixbuf *
+render_icon_name_pixbuf (GtkIconSource *icon_source,
+ GtkStyleContext *context,
+ GtkIconSize size,
+ gint scale)
+{
+ GdkPixbuf *pixbuf;
+ GdkPixbuf *tmp_pixbuf;
+ GtkIconSource tmp_source;
+ GdkScreen *screen;
+ GtkIconTheme *icon_theme;
+ GtkSettings *settings;
+ gint width, height, pixel_size;
+ gint *sizes, *s, dist;
+ GError *error = NULL;
+
+ screen = gtk_style_context_get_screen (context);
+ icon_theme = gtk_icon_theme_get_for_screen (screen);
+ settings = gtk_settings_get_for_screen (screen);
+
+ if (!gtk_icon_size_lookup_for_settings (settings, size, &width, &height))
+ {
+ if (size == (GtkIconSize)-1)
+ {
+ /* Find an available size close to 48 */
+ sizes = gtk_icon_theme_get_icon_sizes (icon_theme, icon_source->source.icon_name);
+ dist = 1000;
+ width = height = 48;
+ for (s = sizes; *s; s++)
+ {
+ if (*s == -1)
+ {
+ width = height = 48;
+ break;
+ }
+ if (*s < 48)
+ {
+ if (48 - *s < dist)
+ {
+ width = height = *s;
+ dist = 48 - *s;
+ }
+ }
+ else
+ {
+ if (*s - 48 < dist)
+ {
+ width = height = *s;
+ dist = *s - 48;
+ }
+ }
+ }
+
+ g_free (sizes);
+ }
+ else
+ {
+ g_warning ("Invalid icon size %u\n", size);
+ width = height = 24;
+ }
+ }
+
+ pixel_size = MIN (width, height);
+
+ if (icon_source->direction != GTK_TEXT_DIR_NONE)
+ {
+ gchar *suffix[3] = { NULL, "-ltr", "-rtl" };
+ gchar *names[3];
+ GtkIconInfo *info;
+
+ names[0] = g_strconcat (icon_source->source.icon_name, suffix[icon_source->direction], NULL);
+ names[1] = icon_source->source.icon_name;
+ names[2] = NULL;
+
+ info = gtk_icon_theme_choose_icon_for_scale (icon_theme,
+ (const char **) names,
+ pixel_size, scale,
+ GTK_ICON_LOOKUP_USE_BUILTIN);
+ g_free (names[0]);
+ if (info)
+ {
+ tmp_pixbuf = gtk_icon_info_load_icon (info, &error);
+ g_object_unref (info);
+ }
+ else
+ tmp_pixbuf = NULL;
+ }
+ else
+ {
+ tmp_pixbuf = gtk_icon_theme_load_icon_for_scale (icon_theme,
+ icon_source->source.icon_name,
+ pixel_size, scale, 0,
+ &error);
+ }
+
+ if (!tmp_pixbuf)
+ {
+ g_warning ("Error loading theme icon '%s' for stock: %s",
+ icon_source->source.icon_name, error ? error->message : "");
+ if (error)
+ g_error_free (error);
+ return NULL;
+ }
+
+ tmp_source = *icon_source;
+ tmp_source.type = GTK_ICON_SOURCE_PIXBUF;
+ tmp_source.source.pixbuf = tmp_pixbuf;
+
+ pixbuf = gtk_render_icon_pixbuf (context, &tmp_source, -1);
+
+ if (!pixbuf)
+ g_warning ("Failed to render icon");
+
+ g_object_unref (tmp_pixbuf);
+
+ return pixbuf;
+}
+
+static GdkPixbuf *
+find_and_render_icon_source (GtkIconSet *icon_set,
+ GtkStyleContext *context,
+ GtkTextDirection direction,
+ GtkStateType state,
+ GtkIconSize size,
+ gint scale)
+{
+ GSList *failed = NULL;
+ GdkPixbuf *pixbuf = NULL;
+
+ /* We treat failure in two different ways:
+ *
+ * A) If loading a source that specifies a filename fails,
+ * we treat that as permanent, and remove the source
+ * from the GtkIconSet. (in ensure_filename_pixbuf ()
+ * B) If loading a themed icon fails, or scaling an icon
+ * fails, we treat that as transient and will try
+ * again next time the icon falls out of the cache
+ * and we need to recreate it.
+ */
+ while (pixbuf == NULL)
+ {
+ GtkIconSource *source = find_best_matching_source (icon_set, direction, state, size, failed);
+
+ if (source == NULL)
+ break;
+
+ switch (source->type)
+ {
+ case GTK_ICON_SOURCE_FILENAME:
+ if (!ensure_filename_pixbuf (icon_set, source))
+ break;
+ /* Fall through */
+ case GTK_ICON_SOURCE_PIXBUF:
+ pixbuf = gtk_render_icon_pixbuf (context, source, size);
+ if (!pixbuf)
+ {
+ g_warning ("Failed to render icon");
+ failed = g_slist_prepend (failed, source);
+ }
+
+ if (scale != 1)
+ {
+ GdkPixbuf *tmp = pixbuf;
+ pixbuf = gdk_pixbuf_scale_simple (pixbuf,
+ gdk_pixbuf_get_width (pixbuf) * scale,
+ gdk_pixbuf_get_height (pixbuf) * scale,
+ GDK_INTERP_BILINEAR);
+ g_object_unref (tmp);
+ }
+ break;
+ case GTK_ICON_SOURCE_ICON_NAME:
+ case GTK_ICON_SOURCE_STATIC_ICON_NAME:
+ pixbuf = render_icon_name_pixbuf (source, context,
+ size, scale);
+ if (!pixbuf)
+ failed = g_slist_prepend (failed, source);
+ break;
+ case GTK_ICON_SOURCE_EMPTY:
+ g_assert_not_reached ();
+ }
+ }
+
+ g_slist_free (failed);
+
+ return pixbuf;
+}
+
+extern GtkIconCache *_builtin_cache;
+
+static GdkPixbuf*
+render_fallback_image (GtkStyleContext *context,
+ GtkTextDirection direction,
+ GtkStateType state,
+ GtkIconSize size)
+{
+ /* This icon can be used for any direction/state/size */
+ static GtkIconSource fallback_source = GTK_ICON_SOURCE_INIT (TRUE, TRUE, TRUE);
+
+ if (fallback_source.type == GTK_ICON_SOURCE_EMPTY)
+ {
+ gint index;
+ GdkPixbuf *pixbuf;
+
+ _gtk_icon_theme_ensure_builtin_cache ();
+
+ index = _gtk_icon_cache_get_directory_index (_builtin_cache, "24");
+ pixbuf = _gtk_icon_cache_get_icon (_builtin_cache, "image-missing", index);
+
+ g_return_val_if_fail(pixbuf != NULL, NULL);
+
+ gtk_icon_source_set_pixbuf (&fallback_source, pixbuf);
+ g_object_unref (pixbuf);
+ }
+
+ return gtk_render_icon_pixbuf (context, &fallback_source, size);
+}
+
+static GdkPixbuf*
+gtk_icon_set_render_icon_pixbuf_for_scale (GtkIconSet *icon_set,
+ GtkStyleContext *context,
+ GtkIconSize size,
+ gint scale)
+{
+ GdkPixbuf *icon = NULL;
+ GtkStateFlags flags = 0;
+ GtkStateType state;
+ GtkTextDirection direction;
+
+ g_return_val_if_fail (icon_set != NULL, NULL);
+ g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
+
+ flags = gtk_style_context_get_state (context);
+ if (flags & GTK_STATE_FLAG_INSENSITIVE)
+ state = GTK_STATE_INSENSITIVE;
+ else if (flags & GTK_STATE_FLAG_PRELIGHT)
+ state = GTK_STATE_PRELIGHT;
+ else
+ state = GTK_STATE_NORMAL;
+
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+ direction = gtk_style_context_get_direction (context);
+G_GNUC_END_IGNORE_DEPRECATIONS;
+
+ if (icon_set->sources)
+ {
+ icon = find_in_cache (icon_set, context, direction, state, size, scale);
+ if (icon)
+ return g_object_ref (icon);
+ }
+
+ if (icon_set->sources)
+ icon = find_and_render_icon_source (icon_set, context, direction, state,
+ size, scale);
+
+ if (icon == NULL)
+ icon = render_fallback_image (context, direction, state, size);
+
+ add_to_cache (icon_set, context, direction, state, size, scale, icon);
+
+ return icon;
+}
+
+/**
+ * gtk_icon_set_render_icon_pixbuf:
+ * @icon_set: a #GtkIconSet
+ * @context: a #GtkStyleContext
+ * @size: (type int): icon size. A size of (GtkIconSize)-1
+ * means render at the size of the source and don't scale.
+ *
+ * Renders an icon using gtk_render_icon_pixbuf(). In most cases,
+ * gtk_widget_render_icon_pixbuf() is better, since it automatically provides
+ * most of the arguments from the current widget settings. This
+ * function never returns %NULL; if the icon can't be rendered
+ * (perhaps because an image file fails to load), a default "missing
+ * image" icon will be returned instead.
+ *
+ * Return value: (transfer full): a #GdkPixbuf to be displayed
+ *
+ * Since: 3.0
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+GdkPixbuf *
+gtk_icon_set_render_icon_pixbuf (GtkIconSet *icon_set,
+ GtkStyleContext *context,
+ GtkIconSize size)
+{
+ g_return_val_if_fail (icon_set != NULL, NULL);
+ g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
+
+ return gtk_icon_set_render_icon_pixbuf_for_scale (icon_set, context, size, 1);
+}
+
+/**
+ * gtk_icon_set_render_icon_surface:
+ * @icon_set: a #GtkIconSet
+ * @context: a #GtkStyleContext
+ * @size: (type int): icon size. A size of (GtkIconSize)-1
+ * means render at the size of the source and don't scale.
+ * @scale: the window scale to render for
+ * @for_window: (allow-none): #GdkWindow to optimize drawing for, or %NULL
+ *
+ * Renders an icon using gtk_render_icon_pixbuf() and converts it to a
+ * cairo surface.
+ *
+ * This function never returns %NULL; if the icon can't be rendered
+ * (perhaps because an image file fails to load), a default "missing
+ * image" icon will be returned instead.
+ *
+ * Return value: (transfer full): a #cairo_surface_t to be displayed
+ *
+ * Since: 3.10
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+cairo_surface_t *
+gtk_icon_set_render_icon_surface (GtkIconSet *icon_set,
+ GtkStyleContext *context,
+ GtkIconSize size,
+ gint scale,
+ GdkWindow *for_window)
+{
+ GdkPixbuf *pixbuf;
+ cairo_surface_t *surface;
+
+ pixbuf = gtk_icon_set_render_icon_pixbuf_for_scale (icon_set, context, size, scale);
+
+ surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, scale, for_window);
+ g_object_unref (pixbuf);
+
+ return surface;
+}
+
+/**
+ * gtk_icon_set_render_icon:
+ * @icon_set: a #GtkIconSet
+ * @style: (allow-none): a #GtkStyle associated with @widget, or %NULL
+ * @direction: text direction
+ * @state: widget state
+ * @size: (type int): icon size. A size of (GtkIconSize)-1
+ * means render at the size of the source and don't scale.
+ * @widget: (allow-none): widget that will display the icon, or %NULL.
+ * The only use that is typically made of this
+ * is to determine the appropriate #GdkScreen.
+ * @detail: (allow-none): detail to pass to the theme engine, or %NULL.
+ * Note that passing a detail of anything but %NULL
+ * will disable caching.
+ *
+ * Renders an icon using gtk_style_render_icon(). In most cases,
+ * gtk_widget_render_icon() is better, since it automatically provides
+ * most of the arguments from the current widget settings. This
+ * function never returns %NULL; if the icon can't be rendered
+ * (perhaps because an image file fails to load), a default "missing
+ * image" icon will be returned instead.
+ *
+ * Return value: (transfer full): a #GdkPixbuf to be displayed
+ *
+ * Deprecated: 3.0: Use gtk_icon_set_render_icon_pixbuf() instead
+ */
+GdkPixbuf*
+gtk_icon_set_render_icon (GtkIconSet *icon_set,
+ GtkStyle *style,
+ GtkTextDirection direction,
+ GtkStateType state,
+ GtkIconSize size,
+ GtkWidget *widget,
+ const char *detail)
+{
+ GdkPixbuf *icon;
+ GtkStyleContext *context = NULL;
+ GtkStateFlags flags = 0;
+
+ g_return_val_if_fail (icon_set != NULL, NULL);
+
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+
+ g_return_val_if_fail (style == NULL || GTK_IS_STYLE (style), NULL);
+
+ if (style && gtk_style_has_context (style))
+ {
+ g_object_get (style, "context", &context, NULL);
+ /* g_object_get returns a refed object */
+ if (context)
+ g_object_unref (context);
+ }
+ else if (widget)
+ {
+ context = gtk_widget_get_style_context (widget);
+ }
+
+ if (!context)
+ return render_fallback_image (context, direction, state, size);
+
+ gtk_style_context_save (context);
+
+ switch (state)
+ {
+ case GTK_STATE_PRELIGHT:
+ flags |= GTK_STATE_FLAG_PRELIGHT;
+ break;
+ case GTK_STATE_INSENSITIVE:
+ flags |= GTK_STATE_FLAG_INSENSITIVE;
+ break;
+ default:
+ break;
+ }
+
+ gtk_style_context_set_state (context, flags);
+ gtk_style_context_set_direction (context, direction);
+
+G_GNUC_END_IGNORE_DEPRECATIONS;
+
+ icon = gtk_icon_set_render_icon_pixbuf (icon_set, context, size);
+
+ gtk_style_context_restore (context);
+
+ return icon;
+}
+
+/* Order sources by their "wildness", so that "wilder" sources are
+ * greater than "specific" sources; for determining ordering,
+ * direction beats state beats size.
+ */
+
+static int
+icon_source_compare (gconstpointer ap, gconstpointer bp)
+{
+ const GtkIconSource *a = ap;
+ const GtkIconSource *b = bp;
+
+ if (!a->any_direction && b->any_direction)
+ return -1;
+ else if (a->any_direction && !b->any_direction)
+ return 1;
+ else if (!a->any_state && b->any_state)
+ return -1;
+ else if (a->any_state && !b->any_state)
+ return 1;
+ else if (!a->any_size && b->any_size)
+ return -1;
+ else if (a->any_size && !b->any_size)
+ return 1;
+ else
+ return 0;
+}
+
+/**
+ * gtk_icon_set_add_source:
+ * @icon_set: a #GtkIconSet
+ * @source: a #GtkIconSource
+ *
+ * Icon sets have a list of #GtkIconSource, which they use as base
+ * icons for rendering icons in different states and sizes. Icons are
+ * scaled, made to look insensitive, etc. in
+ * gtk_icon_set_render_icon(), but #GtkIconSet needs base images to
+ * work with. The base images and when to use them are described by
+ * a #GtkIconSource.
+ *
+ * This function copies @source, so you can reuse the same source immediately
+ * without affecting the icon set.
+ *
+ * An example of when you'd use this function: a web browser's "Back
+ * to Previous Page" icon might point in a different direction in
+ * Hebrew and in English; it might look different when insensitive;
+ * and it might change size depending on toolbar mode (small/large
+ * icons). So a single icon set would contain all those variants of
+ * the icon, and you might add a separate source for each one.
+ *
+ * You should nearly always add a "default" icon source with all
+ * fields wildcarded, which will be used as a fallback if no more
+ * specific source matches. #GtkIconSet always prefers more specific
+ * icon sources to more generic icon sources. The order in which you
+ * add the sources to the icon set does not matter.
+ *
+ * gtk_icon_set_new_from_pixbuf() creates a new icon set with a
+ * default icon source based on the given pixbuf.
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+void
+gtk_icon_set_add_source (GtkIconSet *icon_set,
+ const GtkIconSource *source)
+{
+ g_return_if_fail (icon_set != NULL);
+ g_return_if_fail (source != NULL);
+
+ if (source->type == GTK_ICON_SOURCE_EMPTY)
+ {
+ g_warning ("Useless empty GtkIconSource");
+ return;
+ }
+
+ icon_set->sources = g_slist_insert_sorted (icon_set->sources,
+ gtk_icon_source_copy (source),
+ icon_source_compare);
+}
+
+/**
+ * gtk_icon_set_get_sizes:
+ * @icon_set: a #GtkIconSet
+ * @sizes: (array length=n_sizes) (out) (type int): return location
+ * for array of sizes
+ * @n_sizes: location to store number of elements in returned array
+ *
+ * Obtains a list of icon sizes this icon set can render. The returned
+ * array must be freed with g_free().
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+void
+gtk_icon_set_get_sizes (GtkIconSet *icon_set,
+ GtkIconSize **sizes,
+ gint *n_sizes)
+{
+ GSList *tmp_list;
+ gboolean all_sizes = FALSE;
+ GSList *specifics = NULL;
+
+ g_return_if_fail (icon_set != NULL);
+ g_return_if_fail (sizes != NULL);
+ g_return_if_fail (n_sizes != NULL);
+
+ tmp_list = icon_set->sources;
+ while (tmp_list != NULL)
+ {
+ GtkIconSource *source;
+
+ source = tmp_list->data;
+
+ if (source->any_size)
+ {
+ all_sizes = TRUE;
+ break;
+ }
+ else
+ specifics = g_slist_prepend (specifics, GINT_TO_POINTER (source->size));
+
+ tmp_list = g_slist_next (tmp_list);
+ }
+
+ if (all_sizes)
+ {
+ /* Need to find out what sizes exist */
+ gint i;
+
+ init_icon_sizes ();
+
+ *sizes = g_new (GtkIconSize, icon_sizes_used);
+ *n_sizes = icon_sizes_used - 1;
+
+ i = 1;
+ while (i < icon_sizes_used)
+ {
+ (*sizes)[i - 1] = icon_sizes[i].size;
+ ++i;
+ }
+ }
+ else
+ {
+ gint i;
+
+ *n_sizes = g_slist_length (specifics);
+ *sizes = g_new (GtkIconSize, *n_sizes);
+
+ i = 0;
+ tmp_list = specifics;
+ while (tmp_list != NULL)
+ {
+ (*sizes)[i] = GPOINTER_TO_INT (tmp_list->data);
+
+ ++i;
+ tmp_list = g_slist_next (tmp_list);
+ }
+ }
+
+ g_slist_free (specifics);
+}
+
+
+/**
+ * gtk_icon_source_new:
+ *
+ * Creates a new #GtkIconSource. A #GtkIconSource contains a #GdkPixbuf (or
+ * image filename) that serves as the base image for one or more of the
+ * icons in a #GtkIconSet, along with a specification for which icons in the
+ * icon set will be based on that pixbuf or image file. An icon set contains
+ * a set of icons that represent "the same" logical concept in different states,
+ * different global text directions, and different sizes.
+ *
+ * So for example a web browser's "Back to Previous Page" icon might
+ * point in a different direction in Hebrew and in English; it might
+ * look different when insensitive; and it might change size depending
+ * on toolbar mode (small/large icons). So a single icon set would
+ * contain all those variants of the icon. #GtkIconSet contains a list
+ * of #GtkIconSource from which it can derive specific icon variants in
+ * the set.
+ *
+ * In the simplest case, #GtkIconSet contains one source pixbuf from
+ * which it derives all variants. The convenience function
+ * gtk_icon_set_new_from_pixbuf() handles this case; if you only have
+ * one source pixbuf, just use that function.
+ *
+ * If you want to use a different base pixbuf for different icon
+ * variants, you create multiple icon sources, mark which variants
+ * they'll be used to create, and add them to the icon set with
+ * gtk_icon_set_add_source().
+ *
+ * By default, the icon source has all parameters wildcarded. That is,
+ * the icon source will be used as the base icon for any desired text
+ * direction, widget state, or icon size.
+ *
+ * Return value: a new #GtkIconSource
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+GtkIconSource*
+gtk_icon_source_new (void)
+{
+ GtkIconSource *src;
+
+ src = g_new0 (GtkIconSource, 1);
+
+ src->direction = GTK_TEXT_DIR_NONE;
+ src->size = GTK_ICON_SIZE_INVALID;
+ src->state = GTK_STATE_NORMAL;
+
+ src->any_direction = TRUE;
+ src->any_state = TRUE;
+ src->any_size = TRUE;
+
+ return src;
+}
+
+/**
+ * gtk_icon_source_copy:
+ * @source: a #GtkIconSource
+ *
+ * Creates a copy of @source; mostly useful for language bindings.
+ *
+ * Return value: a new #GtkIconSource
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+GtkIconSource*
+gtk_icon_source_copy (const GtkIconSource *source)
+{
+ GtkIconSource *copy;
+
+ g_return_val_if_fail (source != NULL, NULL);
+
+ copy = g_new (GtkIconSource, 1);
+
+ *copy = *source;
+
+ switch (copy->type)
+ {
+ case GTK_ICON_SOURCE_EMPTY:
+ case GTK_ICON_SOURCE_STATIC_ICON_NAME:
+ break;
+ case GTK_ICON_SOURCE_ICON_NAME:
+ copy->source.icon_name = g_strdup (copy->source.icon_name);
+ break;
+ case GTK_ICON_SOURCE_FILENAME:
+ copy->source.filename = g_strdup (copy->source.filename);
+ if (copy->filename_pixbuf)
+ g_object_ref (copy->filename_pixbuf);
+ break;
+ case GTK_ICON_SOURCE_PIXBUF:
+ g_object_ref (copy->source.pixbuf);
+ break;
+ default:
+ g_assert_not_reached();
+ }
+
+ return copy;
+}
+
+/**
+ * gtk_icon_source_free:
+ * @source: a #GtkIconSource
+ *
+ * Frees a dynamically-allocated icon source, along with its
+ * filename, size, and pixbuf fields if those are not %NULL.
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+void
+gtk_icon_source_free (GtkIconSource *source)
+{
+ g_return_if_fail (source != NULL);
+
+ icon_source_clear (source);
+ g_free (source);
+}
+
+G_DEFINE_BOXED_TYPE (GtkIconSource, gtk_icon_source,
+ gtk_icon_source_copy,
+ gtk_icon_source_free)
+
+static void
+icon_source_clear (GtkIconSource *source)
+{
+ switch (source->type)
+ {
+ case GTK_ICON_SOURCE_EMPTY:
+ break;
+ case GTK_ICON_SOURCE_ICON_NAME:
+ g_free (source->source.icon_name);
+ /* fall thru */
+ case GTK_ICON_SOURCE_STATIC_ICON_NAME:
+ source->source.icon_name = NULL;
+ break;
+ case GTK_ICON_SOURCE_FILENAME:
+ g_free (source->source.filename);
+ source->source.filename = NULL;
+ if (source->filename_pixbuf)
+ g_object_unref (source->filename_pixbuf);
+ source->filename_pixbuf = NULL;
+ break;
+ case GTK_ICON_SOURCE_PIXBUF:
+ g_object_unref (source->source.pixbuf);
+ source->source.pixbuf = NULL;
+ break;
+ default:
+ g_assert_not_reached();
+ }
+
+ source->type = GTK_ICON_SOURCE_EMPTY;
+}
+
+/**
+ * gtk_icon_source_set_filename:
+ * @source: a #GtkIconSource
+ * @filename: (type filename): image file to use
+ *
+ * Sets the name of an image file to use as a base image when creating
+ * icon variants for #GtkIconSet. The filename must be absolute.
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+void
+gtk_icon_source_set_filename (GtkIconSource *source,
+ const gchar *filename)
+{
+ g_return_if_fail (source != NULL);
+ g_return_if_fail (filename == NULL || g_path_is_absolute (filename));
+
+ if (source->type == GTK_ICON_SOURCE_FILENAME &&
+ source->source.filename == filename)
+ return;
+
+ icon_source_clear (source);
+
+ if (filename != NULL)
+ {
+ source->type = GTK_ICON_SOURCE_FILENAME;
+ source->source.filename = g_strdup (filename);
+ }
+}
+
+/**
+ * gtk_icon_source_set_icon_name:
+ * @source: a #GtkIconSource
+ * @icon_name: (allow-none): name of icon to use
+ *
+ * Sets the name of an icon to look up in the current icon theme
+ * to use as a base image when creating icon variants for #GtkIconSet.
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+void
+gtk_icon_source_set_icon_name (GtkIconSource *source,
+ const gchar *icon_name)
+{
+ g_return_if_fail (source != NULL);
+
+ if (source->type == GTK_ICON_SOURCE_ICON_NAME &&
+ source->source.icon_name == icon_name)
+ return;
+
+ icon_source_clear (source);
+
+ if (icon_name != NULL)
+ {
+ source->type = GTK_ICON_SOURCE_ICON_NAME;
+ source->source.icon_name = g_strdup (icon_name);
+ }
+}
+
+/**
+ * gtk_icon_source_set_pixbuf:
+ * @source: a #GtkIconSource
+ * @pixbuf: pixbuf to use as a source
+ *
+ * Sets a pixbuf to use as a base image when creating icon variants
+ * for #GtkIconSet.
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+void
+gtk_icon_source_set_pixbuf (GtkIconSource *source,
+ GdkPixbuf *pixbuf)
+{
+ g_return_if_fail (source != NULL);
+ g_return_if_fail (pixbuf == NULL || GDK_IS_PIXBUF (pixbuf));
+
+ if (source->type == GTK_ICON_SOURCE_PIXBUF &&
+ source->source.pixbuf == pixbuf)
+ return;
+
+ icon_source_clear (source);
+
+ if (pixbuf != NULL)
+ {
+ source->type = GTK_ICON_SOURCE_PIXBUF;
+ source->source.pixbuf = g_object_ref (pixbuf);
+ }
+}
+
+/**
+ * gtk_icon_source_get_filename:
+ * @source: a #GtkIconSource
+ *
+ * Retrieves the source filename, or %NULL if none is set. The
+ * filename is not a copy, and should not be modified or expected to
+ * persist beyond the lifetime of the icon source.
+ *
+ * Return value: (type filename): image filename. This string must not
+ * be modified or freed.
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+const gchar*
+gtk_icon_source_get_filename (const GtkIconSource *source)
+{
+ g_return_val_if_fail (source != NULL, NULL);
+
+ if (source->type == GTK_ICON_SOURCE_FILENAME)
+ return source->source.filename;
+ else
+ return NULL;
+}
+
+/**
+ * gtk_icon_source_get_icon_name:
+ * @source: a #GtkIconSource
+ *
+ * Retrieves the source icon name, or %NULL if none is set. The
+ * icon_name is not a copy, and should not be modified or expected to
+ * persist beyond the lifetime of the icon source.
+ *
+ * Return value: icon name. This string must not be modified or freed.
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+const gchar*
+gtk_icon_source_get_icon_name (const GtkIconSource *source)
+{
+ g_return_val_if_fail (source != NULL, NULL);
+
+ if (source->type == GTK_ICON_SOURCE_ICON_NAME ||
+ source->type == GTK_ICON_SOURCE_STATIC_ICON_NAME)
+ return source->source.icon_name;
+ else
+ return NULL;
+}
+
+/**
+ * gtk_icon_source_get_pixbuf:
+ * @source: a #GtkIconSource
+ *
+ * Retrieves the source pixbuf, or %NULL if none is set.
+ * In addition, if a filename source is in use, this
+ * function in some cases will return the pixbuf from
+ * loaded from the filename. This is, for example, true
+ * for the GtkIconSource passed to the GtkStyle::render_icon()
+ * virtual function. The reference count on the pixbuf is
+ * not incremented.
+ *
+ * Return value: (transfer none): source pixbuf
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+GdkPixbuf*
+gtk_icon_source_get_pixbuf (const GtkIconSource *source)
+{
+ g_return_val_if_fail (source != NULL, NULL);
+
+ if (source->type == GTK_ICON_SOURCE_PIXBUF)
+ return source->source.pixbuf;
+ else if (source->type == GTK_ICON_SOURCE_FILENAME)
+ return source->filename_pixbuf;
+ else
+ return NULL;
+}
+
+/**
+ * gtk_icon_source_set_direction_wildcarded:
+ * @source: a #GtkIconSource
+ * @setting: %TRUE to wildcard the text direction
+ *
+ * If the text direction is wildcarded, this source can be used
+ * as the base image for an icon in any #GtkTextDirection.
+ * If the text direction is not wildcarded, then the
+ * text direction the icon source applies to should be set
+ * with gtk_icon_source_set_direction(), and the icon source
+ * will only be used with that text direction.
+ *
+ * #GtkIconSet prefers non-wildcarded sources (exact matches) over
+ * wildcarded sources, and will use an exact match when possible.
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+void
+gtk_icon_source_set_direction_wildcarded (GtkIconSource *source,
+ gboolean setting)
+{
+ g_return_if_fail (source != NULL);
+
+ source->any_direction = setting != FALSE;
+}
+
+/**
+ * gtk_icon_source_set_state_wildcarded:
+ * @source: a #GtkIconSource
+ * @setting: %TRUE to wildcard the widget state
+ *
+ * If the widget state is wildcarded, this source can be used as the
+ * base image for an icon in any #GtkStateType. If the widget state
+ * is not wildcarded, then the state the source applies to should be
+ * set with gtk_icon_source_set_state() and the icon source will
+ * only be used with that specific state.
+ *
+ * #GtkIconSet prefers non-wildcarded sources (exact matches) over
+ * wildcarded sources, and will use an exact match when possible.
+ *
+ * #GtkIconSet will normally transform wildcarded source images to
+ * produce an appropriate icon for a given state, for example
+ * lightening an image on prelight, but will not modify source images
+ * that match exactly.
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+void
+gtk_icon_source_set_state_wildcarded (GtkIconSource *source,
+ gboolean setting)
+{
+ g_return_if_fail (source != NULL);
+
+ source->any_state = setting != FALSE;
+}
+
+
+/**
+ * gtk_icon_source_set_size_wildcarded:
+ * @source: a #GtkIconSource
+ * @setting: %TRUE to wildcard the widget state
+ *
+ * If the icon size is wildcarded, this source can be used as the base
+ * image for an icon of any size. If the size is not wildcarded, then
+ * the size the source applies to should be set with
+ * gtk_icon_source_set_size() and the icon source will only be used
+ * with that specific size.
+ *
+ * #GtkIconSet prefers non-wildcarded sources (exact matches) over
+ * wildcarded sources, and will use an exact match when possible.
+ *
+ * #GtkIconSet will normally scale wildcarded source images to produce
+ * an appropriate icon at a given size, but will not change the size
+ * of source images that match exactly.
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+void
+gtk_icon_source_set_size_wildcarded (GtkIconSource *source,
+ gboolean setting)
+{
+ g_return_if_fail (source != NULL);
+
+ source->any_size = setting != FALSE;
+}
+
+/**
+ * gtk_icon_source_get_size_wildcarded:
+ * @source: a #GtkIconSource
+ *
+ * Gets the value set by gtk_icon_source_set_size_wildcarded().
+ *
+ * Return value: %TRUE if this icon source is a base for any icon size variant
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+gboolean
+gtk_icon_source_get_size_wildcarded (const GtkIconSource *source)
+{
+ g_return_val_if_fail (source != NULL, TRUE);
+
+ return source->any_size;
+}
+
+/**
+ * gtk_icon_source_get_state_wildcarded:
+ * @source: a #GtkIconSource
+ *
+ * Gets the value set by gtk_icon_source_set_state_wildcarded().
+ *
+ * Return value: %TRUE if this icon source is a base for any widget state variant
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+gboolean
+gtk_icon_source_get_state_wildcarded (const GtkIconSource *source)
+{
+ g_return_val_if_fail (source != NULL, TRUE);
+
+ return source->any_state;
+}
+
+/**
+ * gtk_icon_source_get_direction_wildcarded:
+ * @source: a #GtkIconSource
+ *
+ * Gets the value set by gtk_icon_source_set_direction_wildcarded().
+ *
+ * Return value: %TRUE if this icon source is a base for any text direction variant
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+gboolean
+gtk_icon_source_get_direction_wildcarded (const GtkIconSource *source)
+{
+ g_return_val_if_fail (source != NULL, TRUE);
+
+ return source->any_direction;
+}
+
+/**
+ * gtk_icon_source_set_direction:
+ * @source: a #GtkIconSource
+ * @direction: text direction this source applies to
+ *
+ * Sets the text direction this icon source is intended to be used
+ * with.
+ *
+ * Setting the text direction on an icon source makes no difference
+ * if the text direction is wildcarded. Therefore, you should usually
+ * call gtk_icon_source_set_direction_wildcarded() to un-wildcard it
+ * in addition to calling this function.
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+void
+gtk_icon_source_set_direction (GtkIconSource *source,
+ GtkTextDirection direction)
+{
+ g_return_if_fail (source != NULL);
+
+ source->direction = direction;
+}
+
+/**
+ * gtk_icon_source_set_state:
+ * @source: a #GtkIconSource
+ * @state: widget state this source applies to
+ *
+ * Sets the widget state this icon source is intended to be used
+ * with.
+ *
+ * Setting the widget state on an icon source makes no difference
+ * if the state is wildcarded. Therefore, you should usually
+ * call gtk_icon_source_set_state_wildcarded() to un-wildcard it
+ * in addition to calling this function.
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+void
+gtk_icon_source_set_state (GtkIconSource *source,
+ GtkStateType state)
+{
+ g_return_if_fail (source != NULL);
+
+ source->state = state;
+}
+
+/**
+ * gtk_icon_source_set_size:
+ * @source: a #GtkIconSource
+ * @size: (type int): icon size this source applies to
+ *
+ * Sets the icon size this icon source is intended to be used
+ * with.
+ *
+ * Setting the icon size on an icon source makes no difference
+ * if the size is wildcarded. Therefore, you should usually
+ * call gtk_icon_source_set_size_wildcarded() to un-wildcard it
+ * in addition to calling this function.
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+void
+gtk_icon_source_set_size (GtkIconSource *source,
+ GtkIconSize size)
+{
+ g_return_if_fail (source != NULL);
+
+ source->size = size;
+}
+
+/**
+ * gtk_icon_source_get_direction:
+ * @source: a #GtkIconSource
+ *
+ * Obtains the text direction this icon source applies to. The return
+ * value is only useful/meaningful if the text direction is <emphasis>not</emphasis>
+ * wildcarded.
+ *
+ * Return value: text direction this source matches
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+GtkTextDirection
+gtk_icon_source_get_direction (const GtkIconSource *source)
+{
+ g_return_val_if_fail (source != NULL, 0);
+
+ return source->direction;
+}
+
+/**
+ * gtk_icon_source_get_state:
+ * @source: a #GtkIconSource
+ *
+ * Obtains the widget state this icon source applies to. The return
+ * value is only useful/meaningful if the widget state is <emphasis>not</emphasis>
+ * wildcarded.
+ *
+ * Return value: widget state this source matches
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+GtkStateType
+gtk_icon_source_get_state (const GtkIconSource *source)
+{
+ g_return_val_if_fail (source != NULL, 0);
+
+ return source->state;
+}
+
+/**
+ * gtk_icon_source_get_size:
+ * @source: a #GtkIconSource
+ *
+ * Obtains the icon size this source applies to. The return value
+ * is only useful/meaningful if the icon size is <emphasis>not</emphasis> wildcarded.
+ *
+ * Return value: (type int): icon size this source matches.
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+GtkIconSize
+gtk_icon_source_get_size (const GtkIconSource *source)
+{
+ g_return_val_if_fail (source != NULL, 0);
+
+ return source->size;
+}
+
+#define NUM_CACHED_ICONS 8
+
+typedef struct _CachedIcon CachedIcon;
+
+struct _CachedIcon
+{
+ /* These must all match to use the cached pixbuf.
+ * If any don't match, we must re-render the pixbuf.
+ */
+ GtkStyleContext *style;
+ GtkTextDirection direction;
+ GtkStateType state;
+ GtkIconSize size;
+ gint scale;
+
+ GdkPixbuf *pixbuf;
+};
+
+static void
+ensure_cache_up_to_date (GtkIconSet *icon_set)
+{
+ if (icon_set->cache_serial != cache_serial)
+ {
+ clear_cache (icon_set, TRUE);
+ icon_set->cache_serial = cache_serial;
+ }
+}
+
+static void
+cached_icon_free (CachedIcon *icon)
+{
+ g_object_unref (icon->pixbuf);
+ g_object_unref (icon->style);
+
+ g_free (icon);
+}
+
+static GdkPixbuf *
+find_in_cache (GtkIconSet *icon_set,
+ GtkStyleContext *style_context,
+ GtkTextDirection direction,
+ GtkStateType state,
+ GtkIconSize size,
+ gint scale)
+{
+ GSList *tmp_list;
+ GSList *prev;
+
+ ensure_cache_up_to_date (icon_set);
+
+ prev = NULL;
+ tmp_list = icon_set->cache;
+ while (tmp_list != NULL)
+ {
+ CachedIcon *icon = tmp_list->data;
+
+ if (icon->style == style_context &&
+ icon->direction == direction &&
+ icon->state == state &&
+ (size == (GtkIconSize)-1 || icon->size == size))
+ {
+ if (prev)
+ {
+ /* Move this icon to the front of the list. */
+ prev->next = tmp_list->next;
+ tmp_list->next = icon_set->cache;
+ icon_set->cache = tmp_list;
+ }
+
+ return icon->pixbuf;
+ }
+
+ prev = tmp_list;
+ tmp_list = g_slist_next (tmp_list);
+ }
+
+ return NULL;
+}
+
+static void
+add_to_cache (GtkIconSet *icon_set,
+ GtkStyleContext *style_context,
+ GtkTextDirection direction,
+ GtkStateType state,
+ GtkIconSize size,
+ gint scale,
+ GdkPixbuf *pixbuf)
+{
+ CachedIcon *icon;
+
+ ensure_cache_up_to_date (icon_set);
+
+ g_object_ref (pixbuf);
+
+ icon = g_new (CachedIcon, 1);
+ icon_set->cache = g_slist_prepend (icon_set->cache, icon);
+ icon_set->cache_size++;
+
+ icon->style = g_object_ref (style_context);
+ icon->direction = direction;
+ icon->state = state;
+ icon->size = size;
+ icon->scale = scale;
+ icon->pixbuf = pixbuf;
+ attach_to_style (icon_set, icon->style);
+
+ if (icon_set->cache_size >= NUM_CACHED_ICONS)
+ {
+ /* Remove oldest item in the cache */
+ GSList *tmp_list;
+
+ tmp_list = icon_set->cache;
+
+ /* Find next-to-last link */
+ g_assert (NUM_CACHED_ICONS > 2);
+ while (tmp_list->next->next)
+ tmp_list = tmp_list->next;
+
+ g_assert (tmp_list != NULL);
+ g_assert (tmp_list->next != NULL);
+ g_assert (tmp_list->next->next == NULL);
+
+ /* Free the last icon */
+ icon = tmp_list->next->data;
+
+ g_slist_free (tmp_list->next);
+ tmp_list->next = NULL;
+
+ cached_icon_free (icon);
+ }
+}
+
+static void
+clear_cache (GtkIconSet *icon_set,
+ gboolean style_detach)
+{
+ GSList *cache, *tmp_list;
+ GtkStyleContext *last_style = NULL;
+
+ cache = icon_set->cache;
+ icon_set->cache = NULL;
+ icon_set->cache_size = 0;
+ tmp_list = cache;
+ while (tmp_list != NULL)
+ {
+ CachedIcon *icon = tmp_list->data;
+
+ if (style_detach)
+ {
+ /* simple optimization for the case where the cache
+ * contains contiguous icons from the same style.
+ * it's safe to call detach_from_style more than
+ * once on the same style though.
+ */
+ if (last_style != icon->style)
+ {
+ detach_from_style (icon_set, icon->style);
+ last_style = icon->style;
+ }
+ }
+
+ cached_icon_free (icon);
+
+ tmp_list = g_slist_next (tmp_list);
+ }
+
+ g_slist_free (cache);
+}
+
+static GSList*
+copy_cache (GtkIconSet *icon_set,
+ GtkIconSet *copy_recipient)
+{
+ GSList *tmp_list;
+ GSList *copy = NULL;
+
+ ensure_cache_up_to_date (icon_set);
+
+ tmp_list = icon_set->cache;
+ while (tmp_list != NULL)
+ {
+ CachedIcon *icon = tmp_list->data;
+ CachedIcon *icon_copy = g_new (CachedIcon, 1);
+
+ *icon_copy = *icon;
+
+ attach_to_style (copy_recipient, icon_copy->style);
+ g_object_ref (icon_copy->style);
+
+ g_object_ref (icon_copy->pixbuf);
+
+ icon_copy->size = icon->size;
+
+ copy = g_slist_prepend (copy, icon_copy);
+
+ tmp_list = g_slist_next (tmp_list);
+ }
+
+ return g_slist_reverse (copy);
+}
+
+static void
+attach_to_style (GtkIconSet *icon_set,
+ GtkStyleContext *style_context)
+{
+ GHashTable *table;
+
+ table = g_object_get_qdata (G_OBJECT (style_context),
+ g_quark_try_string ("gtk-style-icon-sets"));
+
+ if (table == NULL)
+ {
+ table = g_hash_table_new (NULL, NULL);
+ g_object_set_qdata_full (G_OBJECT (style_context),
+ g_quark_from_static_string ("gtk-style-icon-sets"),
+ table,
+ style_dnotify);
+ }
+
+ g_hash_table_insert (table, icon_set, icon_set);
+}
+
+static void
+detach_from_style (GtkIconSet *icon_set,
+ GtkStyleContext *style_context)
+{
+ GHashTable *table;
+
+ table = g_object_get_qdata (G_OBJECT (style_context),
+ g_quark_try_string ("gtk-style-icon-sets"));
+
+ if (table != NULL)
+ g_hash_table_remove (table, icon_set);
+}
+
+static void
+iconsets_foreach (gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ GtkIconSet *icon_set = key;
+
+ /* We only need to remove cache entries for the given style;
+ * but that complicates things because in destroy notify
+ * we don't know which style got destroyed, and 95% of the
+ * time all cache entries will have the same style,
+ * so this is faster anyway.
+ */
+
+ clear_cache (icon_set, FALSE);
+}
+
+static void
+style_dnotify (gpointer data)
+{
+ GHashTable *table = data;
+
+ g_hash_table_foreach (table, iconsets_foreach, NULL);
+
+ g_hash_table_destroy (table);
+}
+
+/* This allows the icon set to detect that its cache is out of date. */
+void
+_gtk_icon_set_invalidate_caches (void)
+{
+ ++cache_serial;
+}
+
+/**
+ * _gtk_icon_factory_list_ids:
+ *
+ * Gets all known IDs stored in an existing icon factory.
+ * The strings in the returned list aren't copied.
+ * The list itself should be freed.
+ *
+ * Return value: List of ids in icon factories
+ *
+ * Deprecated: 3.10: Use #GtkIconTheme instead.
+ */
+GList*
+_gtk_icon_factory_list_ids (void)
+{
+ GSList *tmp_list;
+ GList *ids;
+
+ ids = NULL;
+
+ _gtk_icon_factory_get_default_icons ();
+
+ tmp_list = all_icon_factories;
+ while (tmp_list != NULL)
+ {
+ GList *these_ids;
+ GtkIconFactory *factory = GTK_ICON_FACTORY (tmp_list->data);
+ GtkIconFactoryPrivate *priv = factory->priv;
+
+ these_ids = g_hash_table_get_keys (priv->icons);
+
+ ids = g_list_concat (ids, these_ids);
+
+ tmp_list = g_slist_next (tmp_list);
+ }
+
+ return ids;
+}
+
+typedef struct {
+ GSList *sources;
+ gboolean in_source;
+
+} IconFactoryParserData;
+
+typedef struct {
+ gchar *stock_id;
+ gchar *filename;
+ gchar *icon_name;
+ GtkTextDirection direction;
+ GtkIconSize size;
+ GtkStateType state;
+} IconSourceParserData;
+
+static void
+icon_source_start_element (GMarkupParseContext *context,
+ const gchar *element_name,
+ const gchar **names,
+ const gchar **values,
+ gpointer user_data,
+ GError **error)
+{
+ gint i;
+ gchar *stock_id = NULL;
+ gchar *filename = NULL;
+ gchar *icon_name = NULL;
+ gint size = -1;
+ gint direction = -1;
+ gint state = -1;
+ IconFactoryParserData *parser_data;
+ IconSourceParserData *source_data;
+ gchar *error_msg;
+ GQuark error_domain;
+
+ parser_data = (IconFactoryParserData*)user_data;
+
+ if (!parser_data->in_source)
+ {
+ if (strcmp (element_name, "sources") != 0)
+ {
+ error_msg = g_strdup_printf ("Unexpected element %s, expected <sources>", element_name);
+ error_domain = GTK_BUILDER_ERROR_INVALID_TAG;
+ goto error;
+ }
+ parser_data->in_source = TRUE;
+ return;
+ }
+ else
+ {
+ if (strcmp (element_name, "source") != 0)
+ {
+ error_msg = g_strdup_printf ("Unexpected element %s, expected <source>", element_name);
+ error_domain = GTK_BUILDER_ERROR_INVALID_TAG;
+ goto error;
+ }
+ }
+
+ for (i = 0; names[i]; i++)
+ {
+ if (strcmp (names[i], "stock-id") == 0)
+ stock_id = g_strdup (values[i]);
+ else if (strcmp (names[i], "filename") == 0)
+ filename = g_strdup (values[i]);
+ else if (strcmp (names[i], "icon-name") == 0)
+ icon_name = g_strdup (values[i]);
+ else if (strcmp (names[i], "size") == 0)
+ {
+ if (!_gtk_builder_enum_from_string (GTK_TYPE_ICON_SIZE,
+ values[i],
+ &size,
+ error))
+ return;
+ }
+ else if (strcmp (names[i], "direction") == 0)
+ {
+ if (!_gtk_builder_enum_from_string (GTK_TYPE_TEXT_DIRECTION,
+ values[i],
+ &direction,
+ error))
+ return;
+ }
+ else if (strcmp (names[i], "state") == 0)
+ {
+ if (!_gtk_builder_enum_from_string (GTK_TYPE_STATE_TYPE,
+ values[i],
+ &state,
+ error))
+ return;
+ }
+ else
+ {
+ error_msg = g_strdup_printf ("'%s' is not a valid attribute of <%s>",
+ names[i], "source");
+ error_domain = GTK_BUILDER_ERROR_INVALID_ATTRIBUTE;
+ goto error;
+ }
+ }
+
+ if (!stock_id)
+ {
+ error_msg = g_strdup_printf ("<source> requires a stock_id");
+ error_domain = GTK_BUILDER_ERROR_MISSING_ATTRIBUTE;
+ goto error;
+ }
+
+ source_data = g_slice_new (IconSourceParserData);
+ source_data->stock_id = stock_id;
+ source_data->filename = filename;
+ source_data->icon_name = icon_name;
+ source_data->size = size;
+ source_data->direction = direction;
+ source_data->state = state;
+
+ parser_data->sources = g_slist_prepend (parser_data->sources, source_data);
+ return;
+
+ error:
+ {
+ gchar *tmp;
+ gint line_number, char_number;
+
+ g_markup_parse_context_get_position (context, &line_number, &char_number);
+
+ tmp = g_strdup_printf ("%s:%d:%d %s", "input",
+ line_number, char_number, error_msg);
+ g_set_error_literal (error, GTK_BUILDER_ERROR, error_domain, tmp);
+ g_free (tmp);
+ g_free (stock_id);
+ g_free (filename);
+ g_free (icon_name);
+ return;
+ }
+}
+
+static const GMarkupParser icon_source_parser =
+ {
+ icon_source_start_element,
+ };
+
+static gboolean
+gtk_icon_factory_buildable_custom_tag_start (GtkBuildable *buildable,
+ GtkBuilder *builder,
+ GObject *child,
+ const gchar *tagname,
+ GMarkupParser *parser,
+ gpointer *data)
+{
+ g_assert (buildable);
+
+ if (strcmp (tagname, "sources") == 0)
+ {
+ IconFactoryParserData *parser_data;
+
+ parser_data = g_slice_new0 (IconFactoryParserData);
+ *parser = icon_source_parser;
+ *data = parser_data;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static void
+gtk_icon_factory_buildable_custom_tag_end (GtkBuildable *buildable,
+ GtkBuilder *builder,
+ GObject *child,
+ const gchar *tagname,
+ gpointer *user_data)
+{
+ GtkIconFactory *icon_factory;
+
+ icon_factory = GTK_ICON_FACTORY (buildable);
+
+ if (strcmp (tagname, "sources") == 0)
+ {
+ IconFactoryParserData *parser_data;
+ GtkIconSource *icon_source;
+ GtkIconSet *icon_set;
+ GSList *l;
+
+ parser_data = (IconFactoryParserData*)user_data;
+
+ for (l = parser_data->sources; l; l = l->next)
+ {
+ IconSourceParserData *source_data = l->data;
+
+ icon_set = gtk_icon_factory_lookup (icon_factory, source_data->stock_id);
+ if (!icon_set)
+ {
+ icon_set = gtk_icon_set_new ();
+ gtk_icon_factory_add (icon_factory, source_data->stock_id, icon_set);
+ gtk_icon_set_unref (icon_set);
+ }
+
+ icon_source = gtk_icon_source_new ();
+
+ if (source_data->filename)
+ {
+ gchar *filename;
+ filename = _gtk_builder_get_absolute_filename (builder, source_data->filename);
+ gtk_icon_source_set_filename (icon_source, filename);
+ g_free (filename);
+ }
+ if (source_data->icon_name)
+ gtk_icon_source_set_icon_name (icon_source, source_data->icon_name);
+ if (source_data->size != -1)
+ {
+ gtk_icon_source_set_size (icon_source, source_data->size);
+ gtk_icon_source_set_size_wildcarded (icon_source, FALSE);
+ }
+ if (source_data->direction != -1)
+ {
+ gtk_icon_source_set_direction (icon_source, source_data->direction);
+ gtk_icon_source_set_direction_wildcarded (icon_source, FALSE);
+ }
+ if (source_data->state != -1)
+ {
+ gtk_icon_source_set_state (icon_source, source_data->state);
+ gtk_icon_source_set_state_wildcarded (icon_source, FALSE);
+ }
+
+ /* Inline source_add() to avoid creating a copy */
+ g_assert (icon_source->type != GTK_ICON_SOURCE_EMPTY);
+ icon_set->sources = g_slist_insert_sorted (icon_set->sources,
+ icon_source,
+ icon_source_compare);
+
+ g_free (source_data->stock_id);
+ g_free (source_data->filename);
+ g_free (source_data->icon_name);
+ g_slice_free (IconSourceParserData, source_data);
+ }
+ g_slist_free (parser_data->sources);
+ g_slice_free (IconFactoryParserData, parser_data);
+
+ /* TODO: Add an attribute/tag to prevent this.
+ * Usually it's the right thing to do though.
+ */
+ gtk_icon_factory_add_default (icon_factory);
+ }
+}
--- /dev/null
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2000 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __GTK_ICON_FACTORY_H__
+#define __GTK_ICON_FACTORY_H__
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#include <gdk/gdk.h>
+#include <gtk/gtkenums.h>
+#include <gtk/gtktypes.h>
+
+G_BEGIN_DECLS
+
+
+#define GTK_TYPE_ICON_FACTORY (gtk_icon_factory_get_type ())
+#define GTK_ICON_FACTORY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_ICON_FACTORY, GtkIconFactory))
+#define GTK_ICON_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ICON_FACTORY, GtkIconFactoryClass))
+#define GTK_IS_ICON_FACTORY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GTK_TYPE_ICON_FACTORY))
+#define GTK_IS_ICON_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ICON_FACTORY))
+#define GTK_ICON_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ICON_FACTORY, GtkIconFactoryClass))
+#define GTK_TYPE_ICON_SET (gtk_icon_set_get_type ())
+#define GTK_TYPE_ICON_SOURCE (gtk_icon_source_get_type ())
+
+typedef struct _GtkIconFactory GtkIconFactory;
+typedef struct _GtkIconFactoryPrivate GtkIconFactoryPrivate;
+typedef struct _GtkIconFactoryClass GtkIconFactoryClass;
+
+struct _GtkIconFactory
+{
+ GObject parent_instance;
+
+ /*< private >*/
+ GtkIconFactoryPrivate *priv;
+};
+
+struct _GtkIconFactoryClass
+{
+ GObjectClass parent_class;
+
+ /* Padding for future expansion */
+ void (*_gtk_reserved1) (void);
+ void (*_gtk_reserved2) (void);
+ void (*_gtk_reserved3) (void);
+ void (*_gtk_reserved4) (void);
+};
+
+GDK_DEPRECATED_IN_3_10
+GType gtk_icon_factory_get_type (void) G_GNUC_CONST;
+GDK_DEPRECATED_IN_3_10
+GtkIconFactory* gtk_icon_factory_new (void);
+GDK_DEPRECATED_IN_3_10
+void gtk_icon_factory_add (GtkIconFactory *factory,
+ const gchar *stock_id,
+ GtkIconSet *icon_set);
+GDK_DEPRECATED_IN_3_10
+GtkIconSet* gtk_icon_factory_lookup (GtkIconFactory *factory,
+ const gchar *stock_id);
+
+/* Manage the default icon factory stack */
+
+GDK_DEPRECATED_IN_3_10
+void gtk_icon_factory_add_default (GtkIconFactory *factory);
+GDK_DEPRECATED_IN_3_10
+void gtk_icon_factory_remove_default (GtkIconFactory *factory);
+GDK_DEPRECATED_IN_3_10
+GtkIconSet* gtk_icon_factory_lookup_default (const gchar *stock_id);
+
+/* Get preferred real size from registered semantic size. Note that
+ * themes SHOULD use this size, but they aren't required to; for size
+ * requests and such, you should get the actual pixbuf from the icon
+ * set and see what size was rendered.
+ *
+ * This function is intended for people who are scaling icons,
+ * rather than for people who are displaying already-scaled icons.
+ * That is, if you are displaying an icon, you should get the
+ * size from the rendered pixbuf, not from here.
+ */
+
+#ifndef GDK_MULTIHEAD_SAFE
+GDK_AVAILABLE_IN_ALL
+gboolean gtk_icon_size_lookup (GtkIconSize size,
+ gint *width,
+ gint *height);
+#endif /* GDK_MULTIHEAD_SAFE */
+GDK_DEPRECATED_IN_3_10_FOR(gtk_icon_size_lookup)
+gboolean gtk_icon_size_lookup_for_settings (GtkSettings *settings,
+ GtkIconSize size,
+ gint *width,
+ gint *height);
+
+GDK_DEPRECATED_IN_3_10
+GtkIconSize gtk_icon_size_register (const gchar *name,
+ gint width,
+ gint height);
+GDK_DEPRECATED_IN_3_10
+void gtk_icon_size_register_alias (const gchar *alias,
+ GtkIconSize target);
+GDK_DEPRECATED_IN_3_10
+GtkIconSize gtk_icon_size_from_name (const gchar *name);
+GDK_DEPRECATED_IN_3_10
+const gchar* gtk_icon_size_get_name (GtkIconSize size);
+
+/* Icon sets */
+
+GDK_DEPRECATED_IN_3_10
+GType gtk_icon_set_get_type (void) G_GNUC_CONST;
+GDK_DEPRECATED_IN_3_10
+GtkIconSet* gtk_icon_set_new (void);
+GDK_DEPRECATED_IN_3_10
+GtkIconSet* gtk_icon_set_new_from_pixbuf (GdkPixbuf *pixbuf);
+
+GDK_DEPRECATED_IN_3_10
+GtkIconSet* gtk_icon_set_ref (GtkIconSet *icon_set);
+GDK_DEPRECATED_IN_3_10
+void gtk_icon_set_unref (GtkIconSet *icon_set);
+GDK_DEPRECATED_IN_3_10
+GtkIconSet* gtk_icon_set_copy (GtkIconSet *icon_set);
+
+GDK_DEPRECATED_IN_3_0_FOR(gtk_icon_set_render_icon_pixbuf)
+GdkPixbuf* gtk_icon_set_render_icon (GtkIconSet *icon_set,
+ GtkStyle *style,
+ GtkTextDirection direction,
+ GtkStateType state,
+ GtkIconSize size,
+ GtkWidget *widget,
+ const gchar *detail);
+
+GDK_DEPRECATED_IN_3_10
+void gtk_icon_set_add_source (GtkIconSet *icon_set,
+ const GtkIconSource *source);
+
+GDK_DEPRECATED_IN_3_10
+void gtk_icon_set_get_sizes (GtkIconSet *icon_set,
+ GtkIconSize **sizes,
+ gint *n_sizes);
+
+GDK_DEPRECATED_IN_3_10
+GType gtk_icon_source_get_type (void) G_GNUC_CONST;
+GDK_DEPRECATED_IN_3_10
+GtkIconSource* gtk_icon_source_new (void);
+GDK_DEPRECATED_IN_3_10
+GtkIconSource* gtk_icon_source_copy (const GtkIconSource *source);
+GDK_DEPRECATED_IN_3_10
+void gtk_icon_source_free (GtkIconSource *source);
+
+GDK_DEPRECATED_IN_3_10
+void gtk_icon_source_set_filename (GtkIconSource *source,
+ const gchar *filename);
+GDK_DEPRECATED_IN_3_10
+void gtk_icon_source_set_icon_name (GtkIconSource *source,
+ const gchar *icon_name);
+GDK_DEPRECATED_IN_3_10
+void gtk_icon_source_set_pixbuf (GtkIconSource *source,
+ GdkPixbuf *pixbuf);
+
+GDK_DEPRECATED_IN_3_10
+const gchar * gtk_icon_source_get_filename (const GtkIconSource *source);
+GDK_DEPRECATED_IN_3_10
+const gchar * gtk_icon_source_get_icon_name (const GtkIconSource *source);
+GDK_DEPRECATED_IN_3_10
+GdkPixbuf* gtk_icon_source_get_pixbuf (const GtkIconSource *source);
+
+GDK_DEPRECATED_IN_3_10
+void gtk_icon_source_set_direction_wildcarded (GtkIconSource *source,
+ gboolean setting);
+GDK_DEPRECATED_IN_3_10
+void gtk_icon_source_set_state_wildcarded (GtkIconSource *source,
+ gboolean setting);
+GDK_DEPRECATED_IN_3_10
+void gtk_icon_source_set_size_wildcarded (GtkIconSource *source,
+ gboolean setting);
+GDK_DEPRECATED_IN_3_10
+gboolean gtk_icon_source_get_size_wildcarded (const GtkIconSource *source);
+GDK_DEPRECATED_IN_3_10
+gboolean gtk_icon_source_get_state_wildcarded (const GtkIconSource *source);
+GDK_DEPRECATED_IN_3_10
+gboolean gtk_icon_source_get_direction_wildcarded (const GtkIconSource *source);
+GDK_DEPRECATED_IN_3_10
+void gtk_icon_source_set_direction (GtkIconSource *source,
+ GtkTextDirection direction);
+GDK_DEPRECATED_IN_3_10
+void gtk_icon_source_set_state (GtkIconSource *source,
+ GtkStateType state);
+GDK_DEPRECATED_IN_3_10
+void gtk_icon_source_set_size (GtkIconSource *source,
+ GtkIconSize size);
+GDK_DEPRECATED_IN_3_10
+GtkTextDirection gtk_icon_source_get_direction (const GtkIconSource *source);
+GDK_DEPRECATED_IN_3_10
+GtkStateType gtk_icon_source_get_state (const GtkIconSource *source);
+GDK_DEPRECATED_IN_3_10
+GtkIconSize gtk_icon_source_get_size (const GtkIconSource *source);
+
+
+/* ignore this */
+void _gtk_icon_set_invalidate_caches (void);
+GList* _gtk_icon_factory_list_ids (void);
+void _gtk_icon_factory_ensure_default_icons (void);
+
+G_END_DECLS
+
+#endif /* __GTK_ICON_FACTORY_H__ */
--- /dev/null
+/* GTK - The GIMP Toolkit
+ * Copyright (C) Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __GTK_IMAGE_MENU_ITEM_H__
+#define __GTK_IMAGE_MENU_ITEM_H__
+
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#include <gtk/gtkmenuitem.h>
+
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_IMAGE_MENU_ITEM (gtk_image_menu_item_get_type ())
+#define GTK_IMAGE_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_IMAGE_MENU_ITEM, GtkImageMenuItem))
+#define GTK_IMAGE_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_IMAGE_MENU_ITEM, GtkImageMenuItemClass))
+#define GTK_IS_IMAGE_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_IMAGE_MENU_ITEM))
+#define GTK_IS_IMAGE_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_IMAGE_MENU_ITEM))
+#define GTK_IMAGE_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_IMAGE_MENU_ITEM, GtkImageMenuItemClass))
+
+
+typedef struct _GtkImageMenuItem GtkImageMenuItem;
+typedef struct _GtkImageMenuItemPrivate GtkImageMenuItemPrivate;
+typedef struct _GtkImageMenuItemClass GtkImageMenuItemClass;
+
+struct _GtkImageMenuItem
+{
+ GtkMenuItem menu_item;
+
+ /*< private >*/
+ GtkImageMenuItemPrivate *priv;
+};
+
+struct _GtkImageMenuItemClass
+{
+ GtkMenuItemClass parent_class;
+
+ /* Padding for future expansion */
+ void (*_gtk_reserved1) (void);
+ void (*_gtk_reserved2) (void);
+ void (*_gtk_reserved3) (void);
+ void (*_gtk_reserved4) (void);
+};
+
+GDK_DEPRECATED_IN_3_10_FOR(gtk_menu_item_get_type)
+GType gtk_image_menu_item_get_type (void) G_GNUC_CONST;
+GDK_DEPRECATED_IN_3_10_FOR(gtk_menu_item_new)
+GtkWidget* gtk_image_menu_item_new (void);
+GDK_DEPRECATED_IN_3_10_FOR(gtk_menu_item_new_with_label)
+GtkWidget* gtk_image_menu_item_new_with_label (const gchar *label);
+GDK_DEPRECATED_IN_3_10_FOR(gtk_menu_item_new_with_mnemonic)
+GtkWidget* gtk_image_menu_item_new_with_mnemonic (const gchar *label);
+GDK_DEPRECATED_IN_3_10_FOR(gtk_menu_item_new)
+GtkWidget* gtk_image_menu_item_new_from_stock (const gchar *stock_id,
+ GtkAccelGroup *accel_group);
+GDK_DEPRECATED_IN_3_10
+void gtk_image_menu_item_set_always_show_image (GtkImageMenuItem *image_menu_item,
+ gboolean always_show);
+GDK_DEPRECATED_IN_3_10
+gboolean gtk_image_menu_item_get_always_show_image (GtkImageMenuItem *image_menu_item);
+GDK_DEPRECATED_IN_3_10
+void gtk_image_menu_item_set_image (GtkImageMenuItem *image_menu_item,
+ GtkWidget *image);
+GDK_DEPRECATED_IN_3_10
+GtkWidget* gtk_image_menu_item_get_image (GtkImageMenuItem *image_menu_item);
+GDK_DEPRECATED_IN_3_10
+void gtk_image_menu_item_set_use_stock (GtkImageMenuItem *image_menu_item,
+ gboolean use_stock);
+GDK_DEPRECATED_IN_3_10
+gboolean gtk_image_menu_item_get_use_stock (GtkImageMenuItem *image_menu_item);
+GDK_DEPRECATED_IN_3_10
+void gtk_image_menu_item_set_accel_group (GtkImageMenuItem *image_menu_item,
+ GtkAccelGroup *accel_group);
+
+G_END_DECLS
+
+#endif /* __GTK_IMAGE_MENU_ITEM_H__ */
--- /dev/null
+/*
+ * GTK - The GIMP Toolkit
+ * Copyright (C) 1998, 1999 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Author: James Henstridge <james@daa.com.au>
+ *
+ * Modified by the GTK+ Team and others 2003. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#include "config.h"
+
+#define GDK_DISABLE_DEPRECATION_WARNINGS
+
+#include "gtkradioaction.h"
+#include "gtkradiomenuitem.h"
+#include "gtktoggletoolbutton.h"
+#include "gtkintl.h"
+#include "gtkprivate.h"
+
+/**
+ * SECTION:gtkradioaction
+ * @Short_description: An action of which only one in a group can be active
+ * @Title: GtkRadioAction
+ *
+ * A #GtkRadioAction is similar to #GtkRadioMenuItem. A number of radio
+ * actions can be linked together so that only one may be active at any
+ * one time.
+ */
+
+
+struct _GtkRadioActionPrivate
+{
+ GSList *group;
+ gint value;
+};
+
+enum
+{
+ CHANGED,
+ LAST_SIGNAL
+};
+
+enum
+{
+ PROP_0,
+ PROP_VALUE,
+ PROP_GROUP,
+ PROP_CURRENT_VALUE
+};
+
+static void gtk_radio_action_finalize (GObject *object);
+static void gtk_radio_action_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gtk_radio_action_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gtk_radio_action_activate (GtkAction *action);
+static GtkWidget *create_menu_item (GtkAction *action);
+
+
+G_DEFINE_TYPE_WITH_PRIVATE (GtkRadioAction, gtk_radio_action, GTK_TYPE_TOGGLE_ACTION)
+
+static guint radio_action_signals[LAST_SIGNAL] = { 0 };
+
+static void
+gtk_radio_action_class_init (GtkRadioActionClass *klass)
+{
+ GObjectClass *gobject_class;
+ GtkActionClass *action_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+ action_class = GTK_ACTION_CLASS (klass);
+
+ gobject_class->finalize = gtk_radio_action_finalize;
+ gobject_class->set_property = gtk_radio_action_set_property;
+ gobject_class->get_property = gtk_radio_action_get_property;
+
+ action_class->activate = gtk_radio_action_activate;
+
+ action_class->create_menu_item = create_menu_item;
+
+ /**
+ * GtkRadioAction:value:
+ *
+ * The value is an arbitrary integer which can be used as a
+ * convenient way to determine which action in the group is
+ * currently active in an ::activate or ::changed signal handler.
+ * See gtk_radio_action_get_current_value() and #GtkRadioActionEntry
+ * for convenient ways to get and set this property.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_VALUE,
+ g_param_spec_int ("value",
+ P_("The value"),
+ P_("The value returned by gtk_radio_action_get_current_value() when this action is the current action of its group."),
+ G_MININT,
+ G_MAXINT,
+ 0,
+ GTK_PARAM_READWRITE));
+
+ /**
+ * GtkRadioAction:group:
+ *
+ * Sets a new group for a radio action.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_GROUP,
+ g_param_spec_object ("group",
+ P_("Group"),
+ P_("The radio action whose group this action belongs to."),
+ GTK_TYPE_RADIO_ACTION,
+ GTK_PARAM_WRITABLE));
+
+ /**
+ * GtkRadioAction:current-value:
+ *
+ * The value property of the currently active member of the group to which
+ * this action belongs.
+ *
+ * Since: 2.10
+ *
+ * Deprecated: 3.10
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_CURRENT_VALUE,
+ g_param_spec_int ("current-value",
+ P_("The current value"),
+ P_("The value property of the currently active member of the group to which this action belongs."),
+ G_MININT,
+ G_MAXINT,
+ 0,
+ GTK_PARAM_READWRITE));
+
+ /**
+ * GtkRadioAction::changed:
+ * @action: the action on which the signal is emitted
+ * @current: the member of @action<!-- -->s group which has just been activated
+ *
+ * The ::changed signal is emitted on every member of a radio group when the
+ * active member is changed. The signal gets emitted after the ::activate signals
+ * for the previous and current active members.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+ radio_action_signals[CHANGED] =
+ g_signal_new (I_("changed"),
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
+ G_STRUCT_OFFSET (GtkRadioActionClass, changed), NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, GTK_TYPE_RADIO_ACTION);
+}
+
+static void
+gtk_radio_action_init (GtkRadioAction *action)
+{
+ action->private_data = gtk_radio_action_get_instance_private (action);
+ action->private_data->group = g_slist_prepend (NULL, action);
+ action->private_data->value = 0;
+
+ gtk_toggle_action_set_draw_as_radio (GTK_TOGGLE_ACTION (action), TRUE);
+}
+
+/**
+ * gtk_radio_action_new:
+ * @name: A unique name for the action
+ * @label: (allow-none): The label displayed in menu items and on buttons,
+ * or %NULL
+ * @tooltip: (allow-none): A tooltip for this action, or %NULL
+ * @stock_id: (allow-none): The stock icon to display in widgets representing
+ * this action, or %NULL
+ * @value: The value which gtk_radio_action_get_current_value() should
+ * return if this action is selected.
+ *
+ * Creates a new #GtkRadioAction object. To add the action to
+ * a #GtkActionGroup and set the accelerator for the action,
+ * call gtk_action_group_add_action_with_accel().
+ *
+ * Return value: a new #GtkRadioAction
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+GtkRadioAction *
+gtk_radio_action_new (const gchar *name,
+ const gchar *label,
+ const gchar *tooltip,
+ const gchar *stock_id,
+ gint value)
+{
+ g_return_val_if_fail (name != NULL, NULL);
+
+ return g_object_new (GTK_TYPE_RADIO_ACTION,
+ "name", name,
+ "label", label,
+ "tooltip", tooltip,
+ "stock-id", stock_id,
+ "value", value,
+ NULL);
+}
+
+static void
+gtk_radio_action_finalize (GObject *object)
+{
+ GtkRadioAction *action;
+ GSList *tmp_list;
+
+ action = GTK_RADIO_ACTION (object);
+
+ action->private_data->group = g_slist_remove (action->private_data->group, action);
+
+ tmp_list = action->private_data->group;
+
+ while (tmp_list)
+ {
+ GtkRadioAction *tmp_action = tmp_list->data;
+
+ tmp_list = tmp_list->next;
+ tmp_action->private_data->group = action->private_data->group;
+ }
+
+ G_OBJECT_CLASS (gtk_radio_action_parent_class)->finalize (object);
+}
+
+static void
+gtk_radio_action_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GtkRadioAction *radio_action;
+
+ radio_action = GTK_RADIO_ACTION (object);
+
+ switch (prop_id)
+ {
+ case PROP_VALUE:
+ radio_action->private_data->value = g_value_get_int (value);
+ break;
+ case PROP_GROUP:
+ {
+ GtkRadioAction *arg;
+ GSList *slist = NULL;
+
+ if (G_VALUE_HOLDS_OBJECT (value))
+ {
+ arg = GTK_RADIO_ACTION (g_value_get_object (value));
+ if (arg)
+ slist = gtk_radio_action_get_group (arg);
+ gtk_radio_action_set_group (radio_action, slist);
+ }
+ }
+ break;
+ case PROP_CURRENT_VALUE:
+ gtk_radio_action_set_current_value (radio_action,
+ g_value_get_int (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gtk_radio_action_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GtkRadioAction *radio_action;
+
+ radio_action = GTK_RADIO_ACTION (object);
+
+ switch (prop_id)
+ {
+ case PROP_VALUE:
+ g_value_set_int (value, radio_action->private_data->value);
+ break;
+ case PROP_CURRENT_VALUE:
+ g_value_set_int (value,
+ gtk_radio_action_get_current_value (radio_action));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gtk_radio_action_activate (GtkAction *action)
+{
+ GtkRadioAction *radio_action;
+ GtkToggleAction *toggle_action;
+ GtkToggleAction *tmp_action;
+ GSList *tmp_list;
+ gboolean active;
+
+ radio_action = GTK_RADIO_ACTION (action);
+ toggle_action = GTK_TOGGLE_ACTION (action);
+
+ active = gtk_toggle_action_get_active (toggle_action);
+ if (active)
+ {
+ tmp_list = radio_action->private_data->group;
+
+ while (tmp_list)
+ {
+ tmp_action = tmp_list->data;
+ tmp_list = tmp_list->next;
+
+ if (gtk_toggle_action_get_active (tmp_action) &&
+ (tmp_action != toggle_action))
+ {
+ _gtk_toggle_action_set_active (toggle_action, !active);
+
+ break;
+ }
+ }
+ g_object_notify (G_OBJECT (action), "active");
+ }
+ else
+ {
+ _gtk_toggle_action_set_active (toggle_action, !active);
+ g_object_notify (G_OBJECT (action), "active");
+
+ tmp_list = radio_action->private_data->group;
+ while (tmp_list)
+ {
+ tmp_action = tmp_list->data;
+ tmp_list = tmp_list->next;
+
+ if (gtk_toggle_action_get_active (tmp_action) &&
+ (tmp_action != toggle_action))
+ {
+ _gtk_action_emit_activate (GTK_ACTION (tmp_action));
+ break;
+ }
+ }
+
+ tmp_list = radio_action->private_data->group;
+ while (tmp_list)
+ {
+ tmp_action = tmp_list->data;
+ tmp_list = tmp_list->next;
+
+ g_object_notify (G_OBJECT (tmp_action), "current-value");
+
+ g_signal_emit (tmp_action, radio_action_signals[CHANGED], 0, radio_action);
+ }
+ }
+
+ gtk_toggle_action_toggled (toggle_action);
+}
+
+static GtkWidget *
+create_menu_item (GtkAction *action)
+{
+ return g_object_new (GTK_TYPE_CHECK_MENU_ITEM,
+ "draw-as-radio", TRUE,
+ NULL);
+}
+
+/**
+ * gtk_radio_action_get_group:
+ * @action: the action object
+ *
+ * Returns the list representing the radio group for this object.
+ * Note that the returned list is only valid until the next change
+ * to the group.
+ *
+ * A common way to set up a group of radio group is the following:
+ * |[
+ * GSList *group = NULL;
+ * GtkRadioAction *action;
+ *
+ * while (/* more actions to add */)
+ * {
+ * action = gtk_radio_action_new (...);
+ *
+ * gtk_radio_action_set_group (action, group);
+ * group = gtk_radio_action_get_group (action);
+ * }
+ * ]|
+ *
+ * Returns: (element-type GtkRadioAction) (transfer none): the list representing the radio group for this object
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+GSList *
+gtk_radio_action_get_group (GtkRadioAction *action)
+{
+ g_return_val_if_fail (GTK_IS_RADIO_ACTION (action), NULL);
+
+ return action->private_data->group;
+}
+
+/**
+ * gtk_radio_action_set_group:
+ * @action: the action object
+ * @group: (element-type GtkRadioAction): a list representing a radio group
+ *
+ * Sets the radio group for the radio action object.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_radio_action_set_group (GtkRadioAction *action,
+ GSList *group)
+{
+ g_return_if_fail (GTK_IS_RADIO_ACTION (action));
+ g_return_if_fail (!g_slist_find (group, action));
+
+ if (action->private_data->group)
+ {
+ GSList *slist;
+
+ action->private_data->group = g_slist_remove (action->private_data->group, action);
+
+ for (slist = action->private_data->group; slist; slist = slist->next)
+ {
+ GtkRadioAction *tmp_action = slist->data;
+
+ tmp_action->private_data->group = action->private_data->group;
+ }
+ }
+
+ action->private_data->group = g_slist_prepend (group, action);
+
+ if (group)
+ {
+ GSList *slist;
+
+ for (slist = action->private_data->group; slist; slist = slist->next)
+ {
+ GtkRadioAction *tmp_action = slist->data;
+
+ tmp_action->private_data->group = action->private_data->group;
+ }
+ }
+ else
+ {
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
+ }
+}
+
+/**
+ * gtk_radio_action_join_group:
+ * @action: the action object
+ * @group_source: (allow-none): a radio action object whos group we are
+ * joining, or %NULL to remove the radio action from its group
+ *
+ * Joins a radio action object to the group of another radio action object.
+ *
+ * Use this in language bindings instead of the gtk_radio_action_get_group()
+ * and gtk_radio_action_set_group() methods
+ *
+ * A common way to set up a group of radio actions is the following:
+ * |[
+ * GtkRadioAction *action;
+ * GtkRadioAction *last_action;
+ *
+ * while (/* more actions to add */)
+ * {
+ * action = gtk_radio_action_new (...);
+ *
+ * gtk_radio_action_join_group (action, last_action);
+ * last_action = action;
+ * }
+ * ]|
+ *
+ * Since: 3.0
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_radio_action_join_group (GtkRadioAction *action,
+ GtkRadioAction *group_source)
+{
+ g_return_if_fail (GTK_IS_RADIO_ACTION (action));
+ g_return_if_fail (group_source == NULL || GTK_IS_RADIO_ACTION (group_source));
+
+ if (group_source)
+ {
+ GSList *group;
+ group = gtk_radio_action_get_group (group_source);
+
+ if (!group)
+ {
+ /* if we are not already part of a group we need to set up a new one
+ and then get the newly created group */
+ gtk_radio_action_set_group (group_source, NULL);
+ group = gtk_radio_action_get_group (group_source);
+ }
+
+ gtk_radio_action_set_group (action, group);
+ }
+ else
+ {
+ gtk_radio_action_set_group (action, NULL);
+ }
+}
+
+/**
+ * gtk_radio_action_get_current_value:
+ * @action: a #GtkRadioAction
+ *
+ * Obtains the value property of the currently active member of
+ * the group to which @action belongs.
+ *
+ * Return value: The value of the currently active group member
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+gint
+gtk_radio_action_get_current_value (GtkRadioAction *action)
+{
+ GSList *slist;
+
+ g_return_val_if_fail (GTK_IS_RADIO_ACTION (action), 0);
+
+ if (action->private_data->group)
+ {
+ for (slist = action->private_data->group; slist; slist = slist->next)
+ {
+ GtkToggleAction *toggle_action = slist->data;
+
+ if (gtk_toggle_action_get_active (toggle_action))
+ return GTK_RADIO_ACTION (toggle_action)->private_data->value;
+ }
+ }
+
+ return action->private_data->value;
+}
+
+/**
+ * gtk_radio_action_set_current_value:
+ * @action: a #GtkRadioAction
+ * @current_value: the new value
+ *
+ * Sets the currently active group member to the member with value
+ * property @current_value.
+ *
+ * Since: 2.10
+ *
+ * Deprecated: 3.10
+ **/
+void
+gtk_radio_action_set_current_value (GtkRadioAction *action,
+ gint current_value)
+{
+ GSList *slist;
+
+ g_return_if_fail (GTK_IS_RADIO_ACTION (action));
+
+ if (action->private_data->group)
+ {
+ for (slist = action->private_data->group; slist; slist = slist->next)
+ {
+ GtkRadioAction *radio_action = slist->data;
+
+ if (radio_action->private_data->value == current_value)
+ {
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (radio_action),
+ TRUE);
+ return;
+ }
+ }
+ }
+
+ if (action->private_data->value == current_value)
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
+ else
+ g_warning ("Radio group does not contain an action with value '%d'",
+ current_value);
+}
--- /dev/null
+/*
+ * GTK - The GIMP Toolkit
+ * Copyright (C) 1998, 1999 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Author: James Henstridge <james@daa.com.au>
+ *
+ * Modified by the GTK+ Team and others 2003. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __GTK_RADIO_ACTION_H__
+#define __GTK_RADIO_ACTION_H__
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#include <gtk/deprecated/gtktoggleaction.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_RADIO_ACTION (gtk_radio_action_get_type ())
+#define GTK_RADIO_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RADIO_ACTION, GtkRadioAction))
+#define GTK_RADIO_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_RADIO_ACTION, GtkRadioActionClass))
+#define GTK_IS_RADIO_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RADIO_ACTION))
+#define GTK_IS_RADIO_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RADIO_ACTION))
+#define GTK_RADIO_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_RADIO_ACTION, GtkRadioActionClass))
+
+typedef struct _GtkRadioAction GtkRadioAction;
+typedef struct _GtkRadioActionPrivate GtkRadioActionPrivate;
+typedef struct _GtkRadioActionClass GtkRadioActionClass;
+
+struct _GtkRadioAction
+{
+ GtkToggleAction parent;
+
+ /*< private >*/
+ GtkRadioActionPrivate *private_data;
+};
+
+struct _GtkRadioActionClass
+{
+ GtkToggleActionClass parent_class;
+
+ void (* changed) (GtkRadioAction *action, GtkRadioAction *current);
+
+ /* Padding for future expansion */
+ void (*_gtk_reserved1) (void);
+ void (*_gtk_reserved2) (void);
+ void (*_gtk_reserved3) (void);
+ void (*_gtk_reserved4) (void);
+};
+
+GDK_DEPRECATED_IN_3_10
+GType gtk_radio_action_get_type (void) G_GNUC_CONST;
+GDK_DEPRECATED_IN_3_10
+GtkRadioAction *gtk_radio_action_new (const gchar *name,
+ const gchar *label,
+ const gchar *tooltip,
+ const gchar *stock_id,
+ gint value);
+GDK_DEPRECATED_IN_3_10
+GSList *gtk_radio_action_get_group (GtkRadioAction *action);
+GDK_DEPRECATED_IN_3_10
+void gtk_radio_action_set_group (GtkRadioAction *action,
+ GSList *group);
+GDK_DEPRECATED_IN_3_10
+void gtk_radio_action_join_group (GtkRadioAction *action,
+ GtkRadioAction *group_source);
+GDK_DEPRECATED_IN_3_10
+gint gtk_radio_action_get_current_value (GtkRadioAction *action);
+GDK_DEPRECATED_IN_3_10
+void gtk_radio_action_set_current_value (GtkRadioAction *action,
+ gint current_value);
+
+G_END_DECLS
+
+#endif /* __GTK_RADIO_ACTION_H__ */
--- /dev/null
+/* GTK - The GIMP Toolkit
+ * Recent chooser action for GtkUIManager
+ *
+ * Copyright (C) 2007, Emmanuele Bassi
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#define GDK_DISABLE_DEPRECATION_WARNINGS
+
+#include "gtkintl.h"
+#include "gtkrecentaction.h"
+#include "gtkimagemenuitem.h"
+#include "gtkmenutoolbutton.h"
+#include "gtkrecentchooser.h"
+#include "gtkrecentchoosermenu.h"
+#include "gtkrecentchooserutils.h"
+#include "gtkrecentchooserprivate.h"
+#include "gtkprivate.h"
+
+/**
+ * SECTION:gtkrecentaction
+ * @Short_description: An action of which represents a list of recently used files
+ * @Title: GtkRecentAction
+ *
+ * A #GtkRecentAction represents a list of recently used files, which
+ * can be shown by widgets such as #GtkRecentChooserDialog or
+ * #GtkRecentChooserMenu.
+ *
+ * To construct a submenu showing recently used files, use a #GtkRecentAction
+ * as the action for a <menuitem>. To construct a menu toolbutton showing
+ * the recently used files in the popup menu, use a #GtkRecentAction as the
+ * action for a <toolitem> element.
+ */
+
+
+#define FALLBACK_ITEM_LIMIT 10
+
+
+struct _GtkRecentActionPrivate
+{
+ GtkRecentManager *manager;
+
+ guint show_numbers : 1;
+
+ /* RecentChooser properties */
+ guint show_private : 1;
+ guint show_not_found : 1;
+ guint show_tips : 1;
+ guint show_icons : 1;
+ guint local_only : 1;
+
+ gint limit;
+
+ GtkRecentSortType sort_type;
+ GtkRecentSortFunc sort_func;
+ gpointer sort_data;
+ GDestroyNotify data_destroy;
+
+ GtkRecentFilter *current_filter;
+
+ GSList *choosers;
+ GtkRecentChooser *current_chooser;
+};
+
+enum
+{
+ PROP_0,
+
+ PROP_SHOW_NUMBERS
+};
+
+static void gtk_recent_chooser_iface_init (GtkRecentChooserIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (GtkRecentAction,
+ gtk_recent_action,
+ GTK_TYPE_ACTION,
+ G_ADD_PRIVATE (GtkRecentAction)
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_RECENT_CHOOSER,
+ gtk_recent_chooser_iface_init));
+
+static gboolean
+gtk_recent_action_set_current_uri (GtkRecentChooser *chooser,
+ const gchar *uri,
+ GError **error)
+{
+ GtkRecentAction *action = GTK_RECENT_ACTION (chooser);
+ GtkRecentActionPrivate *priv = action->priv;
+ GSList *l;
+
+ for (l = priv->choosers; l; l = l->next)
+ {
+ GtkRecentChooser *recent_chooser = l->data;
+
+ if (!gtk_recent_chooser_set_current_uri (recent_chooser, uri, error))
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gchar *
+gtk_recent_action_get_current_uri (GtkRecentChooser *chooser)
+{
+ GtkRecentAction *recent_action = GTK_RECENT_ACTION (chooser);
+ GtkRecentActionPrivate *priv = recent_action->priv;
+
+ if (priv->current_chooser)
+ return gtk_recent_chooser_get_current_uri (priv->current_chooser);
+
+ return NULL;
+}
+
+static gboolean
+gtk_recent_action_select_uri (GtkRecentChooser *chooser,
+ const gchar *uri,
+ GError **error)
+{
+ GtkRecentAction *action = GTK_RECENT_ACTION (chooser);
+ GtkRecentActionPrivate *priv = action->priv;
+ GSList *l;
+
+ for (l = priv->choosers; l; l = l->next)
+ {
+ GtkRecentChooser *recent_chooser = l->data;
+
+ if (!gtk_recent_chooser_select_uri (recent_chooser, uri, error))
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void
+gtk_recent_action_unselect_uri (GtkRecentChooser *chooser,
+ const gchar *uri)
+{
+ GtkRecentAction *action = GTK_RECENT_ACTION (chooser);
+ GtkRecentActionPrivate *priv = action->priv;
+ GSList *l;
+
+ for (l = priv->choosers; l; l = l->next)
+ {
+ GtkRecentChooser *chooser = l->data;
+
+ gtk_recent_chooser_unselect_uri (chooser, uri);
+ }
+}
+
+static void
+gtk_recent_action_select_all (GtkRecentChooser *chooser)
+{
+ g_warning ("This function is not implemented for "
+ "widgets of class '%s'",
+ g_type_name (G_OBJECT_TYPE (chooser)));
+}
+
+static void
+gtk_recent_action_unselect_all (GtkRecentChooser *chooser)
+{
+ g_warning ("This function is not implemented for "
+ "widgets of class '%s'",
+ g_type_name (G_OBJECT_TYPE (chooser)));
+}
+
+
+static GList *
+gtk_recent_action_get_items (GtkRecentChooser *chooser)
+{
+ GtkRecentAction *action = GTK_RECENT_ACTION (chooser);
+ GtkRecentActionPrivate *priv = action->priv;
+
+ return _gtk_recent_chooser_get_items (chooser,
+ priv->current_filter,
+ priv->sort_func,
+ priv->sort_data);
+}
+
+static GtkRecentManager *
+gtk_recent_action_get_recent_manager (GtkRecentChooser *chooser)
+{
+ return GTK_RECENT_ACTION (chooser)->priv->manager;
+}
+
+static void
+gtk_recent_action_set_sort_func (GtkRecentChooser *chooser,
+ GtkRecentSortFunc sort_func,
+ gpointer sort_data,
+ GDestroyNotify data_destroy)
+{
+ GtkRecentAction *action = GTK_RECENT_ACTION (chooser);
+ GtkRecentActionPrivate *priv = action->priv;
+ GSList *l;
+
+ if (priv->data_destroy)
+ {
+ priv->data_destroy (priv->sort_data);
+ priv->data_destroy = NULL;
+ }
+
+ priv->sort_func = NULL;
+ priv->sort_data = NULL;
+
+ if (sort_func)
+ {
+ priv->sort_func = sort_func;
+ priv->sort_data = sort_data;
+ priv->data_destroy = data_destroy;
+ }
+
+ for (l = priv->choosers; l; l = l->next)
+ {
+ GtkRecentChooser *chooser_menu = l->data;
+
+ gtk_recent_chooser_set_sort_func (chooser_menu, priv->sort_func,
+ priv->sort_data,
+ priv->data_destroy);
+ }
+}
+
+static void
+set_current_filter (GtkRecentAction *action,
+ GtkRecentFilter *filter)
+{
+ GtkRecentActionPrivate *priv = action->priv;
+
+ g_object_ref (action);
+
+ if (priv->current_filter)
+ g_object_unref (priv->current_filter);
+
+ priv->current_filter = filter;
+
+ if (priv->current_filter)
+ g_object_ref_sink (priv->current_filter);
+
+ g_object_notify (G_OBJECT (action), "filter");
+
+ g_object_unref (action);
+}
+
+static void
+gtk_recent_action_add_filter (GtkRecentChooser *chooser,
+ GtkRecentFilter *filter)
+{
+ GtkRecentAction *action = GTK_RECENT_ACTION (chooser);
+ GtkRecentActionPrivate *priv = action->priv;
+
+ if (priv->current_filter != filter)
+ set_current_filter (GTK_RECENT_ACTION (chooser), filter);
+}
+
+static void
+gtk_recent_action_remove_filter (GtkRecentChooser *chooser,
+ GtkRecentFilter *filter)
+{
+ GtkRecentAction *action = GTK_RECENT_ACTION (chooser);
+ GtkRecentActionPrivate *priv = action->priv;
+
+ if (priv->current_filter == filter)
+ set_current_filter (GTK_RECENT_ACTION (chooser), NULL);
+}
+
+static GSList *
+gtk_recent_action_list_filters (GtkRecentChooser *chooser)
+{
+ GtkRecentAction *action = GTK_RECENT_ACTION (chooser);
+ GtkRecentActionPrivate *priv = action->priv;
+ GSList *retval = NULL;
+ GtkRecentFilter *current_filter;
+
+ current_filter = priv->current_filter;
+ retval = g_slist_prepend (retval, current_filter);
+
+ return retval;
+}
+
+
+static void
+gtk_recent_chooser_iface_init (GtkRecentChooserIface *iface)
+{
+ iface->set_current_uri = gtk_recent_action_set_current_uri;
+ iface->get_current_uri = gtk_recent_action_get_current_uri;
+ iface->select_uri = gtk_recent_action_select_uri;
+ iface->unselect_uri = gtk_recent_action_unselect_uri;
+ iface->select_all = gtk_recent_action_select_all;
+ iface->unselect_all = gtk_recent_action_unselect_all;
+ iface->get_items = gtk_recent_action_get_items;
+ iface->get_recent_manager = gtk_recent_action_get_recent_manager;
+ iface->set_sort_func = gtk_recent_action_set_sort_func;
+ iface->add_filter = gtk_recent_action_add_filter;
+ iface->remove_filter = gtk_recent_action_remove_filter;
+ iface->list_filters = gtk_recent_action_list_filters;
+}
+
+static void
+gtk_recent_action_activate (GtkAction *action)
+{
+ GtkRecentAction *recent_action = GTK_RECENT_ACTION (action);
+ GtkRecentActionPrivate *priv = recent_action->priv;
+
+ /* we have probably been invoked by a menu tool button or by a
+ * direct call of gtk_action_activate(); since no item has been
+ * selected, we must unset the current recent chooser pointer
+ */
+ priv->current_chooser = NULL;
+}
+
+static void
+delegate_selection_changed (GtkRecentAction *action,
+ GtkRecentChooser *chooser)
+{
+ GtkRecentActionPrivate *priv = action->priv;
+
+ priv->current_chooser = chooser;
+
+ g_signal_emit_by_name (action, "selection-changed");
+}
+
+static void
+delegate_item_activated (GtkRecentAction *action,
+ GtkRecentChooser *chooser)
+{
+ GtkRecentActionPrivate *priv = action->priv;
+
+ priv->current_chooser = chooser;
+
+ g_signal_emit_by_name (action, "item-activated");
+}
+
+static void
+gtk_recent_action_connect_proxy (GtkAction *action,
+ GtkWidget *widget)
+{
+ GtkRecentAction *recent_action = GTK_RECENT_ACTION (action);
+ GtkRecentActionPrivate *priv = recent_action->priv;
+
+ /* it can only be a recent chooser implementor anyway... */
+ if (GTK_IS_RECENT_CHOOSER (widget) &&
+ !g_slist_find (priv->choosers, widget))
+ {
+ if (priv->sort_func)
+ {
+ gtk_recent_chooser_set_sort_func (GTK_RECENT_CHOOSER (widget),
+ priv->sort_func,
+ priv->sort_data,
+ priv->data_destroy);
+ }
+
+ g_signal_connect_swapped (widget, "selection_changed",
+ G_CALLBACK (delegate_selection_changed),
+ action);
+ g_signal_connect_swapped (widget, "item-activated",
+ G_CALLBACK (delegate_item_activated),
+ action);
+ }
+
+ if (GTK_ACTION_CLASS (gtk_recent_action_parent_class)->connect_proxy)
+ GTK_ACTION_CLASS (gtk_recent_action_parent_class)->connect_proxy (action, widget);
+}
+
+static void
+gtk_recent_action_disconnect_proxy (GtkAction *action,
+ GtkWidget *widget)
+{
+ GtkRecentAction *recent_action = GTK_RECENT_ACTION (action);
+ GtkRecentActionPrivate *priv = recent_action->priv;
+
+ /* if it was one of the recent choosers we created, remove it
+ * from the list
+ */
+ if (g_slist_find (priv->choosers, widget))
+ priv->choosers = g_slist_remove (priv->choosers, widget);
+
+ if (GTK_ACTION_CLASS (gtk_recent_action_parent_class)->disconnect_proxy)
+ GTK_ACTION_CLASS (gtk_recent_action_parent_class)->disconnect_proxy (action, widget);
+}
+
+static GtkWidget *
+gtk_recent_action_create_menu (GtkAction *action)
+{
+ GtkRecentAction *recent_action = GTK_RECENT_ACTION (action);
+ GtkRecentActionPrivate *priv = recent_action->priv;
+ GtkWidget *widget;
+
+ widget = g_object_new (GTK_TYPE_RECENT_CHOOSER_MENU,
+ "show-private", priv->show_private,
+ "show-not-found", priv->show_not_found,
+ "show-tips", priv->show_tips,
+ "show-icons", priv->show_icons,
+ "show-numbers", priv->show_numbers,
+ "limit", priv->limit,
+ "sort-type", priv->sort_type,
+ "recent-manager", priv->manager,
+ "filter", priv->current_filter,
+ "local-only", priv->local_only,
+ NULL);
+
+ if (priv->sort_func)
+ {
+ gtk_recent_chooser_set_sort_func (GTK_RECENT_CHOOSER (widget),
+ priv->sort_func,
+ priv->sort_data,
+ priv->data_destroy);
+ }
+
+ g_signal_connect_swapped (widget, "selection_changed",
+ G_CALLBACK (delegate_selection_changed),
+ recent_action);
+ g_signal_connect_swapped (widget, "item-activated",
+ G_CALLBACK (delegate_item_activated),
+ recent_action);
+
+ /* keep track of the choosers we create */
+ priv->choosers = g_slist_prepend (priv->choosers, widget);
+
+ return widget;
+}
+
+static GtkWidget *
+gtk_recent_action_create_menu_item (GtkAction *action)
+{
+ GtkWidget *menu;
+ GtkWidget *menuitem;
+
+ menu = gtk_recent_action_create_menu (action);
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+ menuitem = g_object_new (GTK_TYPE_IMAGE_MENU_ITEM, NULL);
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
+ gtk_widget_show (menu);
+
+ return menuitem;
+}
+
+static GtkWidget *
+gtk_recent_action_create_tool_item (GtkAction *action)
+{
+ GtkWidget *menu;
+ GtkWidget *toolitem;
+
+ menu = gtk_recent_action_create_menu (action);
+ toolitem = g_object_new (GTK_TYPE_MENU_TOOL_BUTTON, NULL);
+ gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (toolitem), menu);
+ gtk_widget_show (menu);
+
+ return toolitem;
+}
+
+static void
+set_recent_manager (GtkRecentAction *action,
+ GtkRecentManager *manager)
+{
+ GtkRecentActionPrivate *priv = action->priv;
+
+ if (manager)
+ priv->manager = NULL;
+ else
+ priv->manager = gtk_recent_manager_get_default ();
+}
+
+static void
+gtk_recent_action_finalize (GObject *gobject)
+{
+ GtkRecentAction *action = GTK_RECENT_ACTION (gobject);
+ GtkRecentActionPrivate *priv = action->priv;
+
+ priv->manager = NULL;
+
+ if (priv->data_destroy)
+ {
+ priv->data_destroy (priv->sort_data);
+ priv->data_destroy = NULL;
+ }
+
+ priv->sort_data = NULL;
+ priv->sort_func = NULL;
+
+ g_slist_free (priv->choosers);
+
+ G_OBJECT_CLASS (gtk_recent_action_parent_class)->finalize (gobject);
+}
+
+static void
+gtk_recent_action_dispose (GObject *gobject)
+{
+ GtkRecentAction *action = GTK_RECENT_ACTION (gobject);
+ GtkRecentActionPrivate *priv = action->priv;
+
+ if (priv->current_filter)
+ {
+ g_object_unref (priv->current_filter);
+ priv->current_filter = NULL;
+ }
+
+ G_OBJECT_CLASS (gtk_recent_action_parent_class)->dispose (gobject);
+}
+
+static void
+gtk_recent_action_set_property (GObject *gobject,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GtkRecentAction *action = GTK_RECENT_ACTION (gobject);
+ GtkRecentActionPrivate *priv = action->priv;
+
+ switch (prop_id)
+ {
+ case PROP_SHOW_NUMBERS:
+ priv->show_numbers = g_value_get_boolean (value);
+ break;
+ case GTK_RECENT_CHOOSER_PROP_SHOW_PRIVATE:
+ priv->show_private = g_value_get_boolean (value);
+ break;
+ case GTK_RECENT_CHOOSER_PROP_SHOW_NOT_FOUND:
+ priv->show_not_found = g_value_get_boolean (value);
+ break;
+ case GTK_RECENT_CHOOSER_PROP_SHOW_TIPS:
+ priv->show_tips = g_value_get_boolean (value);
+ break;
+ case GTK_RECENT_CHOOSER_PROP_SHOW_ICONS:
+ priv->show_icons = g_value_get_boolean (value);
+ break;
+ case GTK_RECENT_CHOOSER_PROP_LIMIT:
+ priv->limit = g_value_get_int (value);
+ break;
+ case GTK_RECENT_CHOOSER_PROP_LOCAL_ONLY:
+ priv->local_only = g_value_get_boolean (value);
+ break;
+ case GTK_RECENT_CHOOSER_PROP_SORT_TYPE:
+ priv->sort_type = g_value_get_enum (value);
+ break;
+ case GTK_RECENT_CHOOSER_PROP_FILTER:
+ set_current_filter (action, g_value_get_object (value));
+ break;
+ case GTK_RECENT_CHOOSER_PROP_SELECT_MULTIPLE:
+ g_warning ("%s: Choosers of type `%s' do not support selecting multiple items.",
+ G_STRFUNC,
+ G_OBJECT_TYPE_NAME (gobject));
+ return;
+ case GTK_RECENT_CHOOSER_PROP_RECENT_MANAGER:
+ set_recent_manager (action, g_value_get_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
+ return;
+ }
+}
+
+static void
+gtk_recent_action_get_property (GObject *gobject,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GtkRecentAction *action = GTK_RECENT_ACTION (gobject);
+ GtkRecentActionPrivate *priv = action->priv;
+
+ switch (prop_id)
+ {
+ case PROP_SHOW_NUMBERS:
+ g_value_set_boolean (value, priv->show_numbers);
+ break;
+ case GTK_RECENT_CHOOSER_PROP_SHOW_PRIVATE:
+ g_value_set_boolean (value, priv->show_private);
+ break;
+ case GTK_RECENT_CHOOSER_PROP_SHOW_NOT_FOUND:
+ g_value_set_boolean (value, priv->show_not_found);
+ break;
+ case GTK_RECENT_CHOOSER_PROP_SHOW_TIPS:
+ g_value_set_boolean (value, priv->show_tips);
+ break;
+ case GTK_RECENT_CHOOSER_PROP_SHOW_ICONS:
+ g_value_set_boolean (value, priv->show_icons);
+ break;
+ case GTK_RECENT_CHOOSER_PROP_LIMIT:
+ g_value_set_int (value, priv->limit);
+ break;
+ case GTK_RECENT_CHOOSER_PROP_LOCAL_ONLY:
+ g_value_set_boolean (value, priv->local_only);
+ break;
+ case GTK_RECENT_CHOOSER_PROP_SORT_TYPE:
+ g_value_set_enum (value, priv->sort_type);
+ break;
+ case GTK_RECENT_CHOOSER_PROP_FILTER:
+ g_value_set_object (value, priv->current_filter);
+ break;
+ case GTK_RECENT_CHOOSER_PROP_SELECT_MULTIPLE:
+ g_value_set_boolean (value, FALSE);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gtk_recent_action_class_init (GtkRecentActionClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GtkActionClass *action_class = GTK_ACTION_CLASS (klass);
+
+ gobject_class->finalize = gtk_recent_action_finalize;
+ gobject_class->dispose = gtk_recent_action_dispose;
+ gobject_class->set_property = gtk_recent_action_set_property;
+ gobject_class->get_property = gtk_recent_action_get_property;
+
+ action_class->activate = gtk_recent_action_activate;
+ action_class->connect_proxy = gtk_recent_action_connect_proxy;
+ action_class->disconnect_proxy = gtk_recent_action_disconnect_proxy;
+ action_class->create_menu_item = gtk_recent_action_create_menu_item;
+ action_class->create_tool_item = gtk_recent_action_create_tool_item;
+ action_class->create_menu = gtk_recent_action_create_menu;
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+ action_class->menu_item_type = GTK_TYPE_IMAGE_MENU_ITEM;
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+ action_class->toolbar_item_type = GTK_TYPE_MENU_TOOL_BUTTON;
+
+ _gtk_recent_chooser_install_properties (gobject_class);
+
+ /**
+ * GtkRecentAction:show-numbers:
+ *
+ * Whether the items should be displayed with a number.
+ *
+ * Deprecated: 3.10
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_SHOW_NUMBERS,
+ g_param_spec_boolean ("show-numbers",
+ P_("Show Numbers"),
+ P_("Whether the items should be displayed with a number"),
+ FALSE,
+ G_PARAM_READWRITE));
+
+}
+
+static void
+gtk_recent_action_init (GtkRecentAction *action)
+{
+ GtkRecentActionPrivate *priv;
+
+ action->priv = priv = gtk_recent_action_get_instance_private (action);
+
+ priv->show_numbers = FALSE;
+ priv->show_icons = TRUE;
+ priv->show_tips = FALSE;
+ priv->show_not_found = TRUE;
+ priv->show_private = FALSE;
+ priv->local_only = TRUE;
+
+ priv->limit = FALLBACK_ITEM_LIMIT;
+
+ priv->sort_type = GTK_RECENT_SORT_NONE;
+ priv->sort_func = NULL;
+ priv->sort_data = NULL;
+ priv->data_destroy = NULL;
+
+ priv->current_filter = NULL;
+
+ priv->manager = NULL;
+}
+
+/**
+ * gtk_recent_action_new:
+ * @name: a unique name for the action
+ * @label: (allow-none): the label displayed in menu items and on buttons,
+ * or %NULL
+ * @tooltip: (allow-none): a tooltip for the action, or %NULL
+ * @stock_id: (allow-none): the stock icon to display in widgets representing
+ * the action, or %NULL
+ *
+ * Creates a new #GtkRecentAction object. To add the action to
+ * a #GtkActionGroup and set the accelerator for the action,
+ * call gtk_action_group_add_action_with_accel().
+ *
+ * Return value: the newly created #GtkRecentAction.
+ *
+ * Since: 2.12
+ *
+ * Deprecated: 3.10
+ */
+GtkAction *
+gtk_recent_action_new (const gchar *name,
+ const gchar *label,
+ const gchar *tooltip,
+ const gchar *stock_id)
+{
+ g_return_val_if_fail (name != NULL, NULL);
+
+ return g_object_new (GTK_TYPE_RECENT_ACTION,
+ "name", name,
+ "label", label,
+ "tooltip", tooltip,
+ "stock-id", stock_id,
+ NULL);
+}
+
+/**
+ * gtk_recent_action_new_for_manager:
+ * @name: a unique name for the action
+ * @label: (allow-none): the label displayed in menu items and on buttons,
+ * or %NULL
+ * @tooltip: (allow-none): a tooltip for the action, or %NULL
+ * @stock_id: (allow-none): the stock icon to display in widgets representing
+ * the action, or %NULL
+ * @manager: (allow-none): a #GtkRecentManager, or %NULL for using the default
+ * #GtkRecentManager
+ *
+ * Creates a new #GtkRecentAction object. To add the action to
+ * a #GtkActionGroup and set the accelerator for the action,
+ * call gtk_action_group_add_action_with_accel().
+ *
+ * Return value: the newly created #GtkRecentAction
+ *
+ * Since: 2.12
+ *
+ * Deprecated: 3.10
+ */
+GtkAction *
+gtk_recent_action_new_for_manager (const gchar *name,
+ const gchar *label,
+ const gchar *tooltip,
+ const gchar *stock_id,
+ GtkRecentManager *manager)
+{
+ g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (manager == NULL || GTK_IS_RECENT_MANAGER (manager), NULL);
+
+ return g_object_new (GTK_TYPE_RECENT_ACTION,
+ "name", name,
+ "label", label,
+ "tooltip", tooltip,
+ "stock-id", stock_id,
+ "recent-manager", manager,
+ NULL);
+}
+
+/**
+ * gtk_recent_action_get_show_numbers:
+ * @action: a #GtkRecentAction
+ *
+ * Returns the value set by gtk_recent_chooser_menu_set_show_numbers().
+ *
+ * Return value: %TRUE if numbers should be shown.
+ *
+ * Since: 2.12
+ *
+ * Deprecated: 3.10
+ */
+gboolean
+gtk_recent_action_get_show_numbers (GtkRecentAction *action)
+{
+ g_return_val_if_fail (GTK_IS_RECENT_ACTION (action), FALSE);
+
+ return action->priv->show_numbers;
+}
+
+/**
+ * gtk_recent_action_set_show_numbers:
+ * @action: a #GtkRecentAction
+ * @show_numbers: %TRUE if the shown items should be numbered
+ *
+ * Sets whether a number should be added to the items shown by the
+ * widgets representing @action. The numbers are shown to provide
+ * a unique character for a mnemonic to be used inside the menu item's
+ * label. Only the first ten items get a number to avoid clashes.
+ *
+ * Since: 2.12
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_recent_action_set_show_numbers (GtkRecentAction *action,
+ gboolean show_numbers)
+{
+ GtkRecentActionPrivate *priv;
+
+ g_return_if_fail (GTK_IS_RECENT_ACTION (action));
+
+ priv = action->priv;
+
+ if (priv->show_numbers != show_numbers)
+ {
+ g_object_ref (action);
+
+ priv->show_numbers = show_numbers;
+
+ g_object_notify (G_OBJECT (action), "show-numbers");
+ g_object_unref (action);
+ }
+}
--- /dev/null
+/* GTK - The GIMP Toolkit
+ * Recent chooser action for GtkUIManager
+ *
+ * Copyright (C) 2007, Emmanuele Bassi
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GTK_RECENT_ACTION_H__
+#define __GTK_RECENT_ACTION_H__
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#include <gtk/deprecated/gtkaction.h>
+#include <gtk/gtkrecentmanager.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_RECENT_ACTION (gtk_recent_action_get_type ())
+#define GTK_RECENT_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RECENT_ACTION, GtkRecentAction))
+#define GTK_IS_RECENT_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RECENT_ACTION))
+#define GTK_RECENT_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_RECENT_ACTION, GtkRecentActionClass))
+#define GTK_IS_RECENT_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RECENT_ACTION))
+#define GTK_RECENT_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RECENT_ACTION, GtkRecentActionClass))
+
+typedef struct _GtkRecentAction GtkRecentAction;
+typedef struct _GtkRecentActionPrivate GtkRecentActionPrivate;
+typedef struct _GtkRecentActionClass GtkRecentActionClass;
+
+struct _GtkRecentAction
+{
+ GtkAction parent_instance;
+
+ /*< private >*/
+ GtkRecentActionPrivate *priv;
+};
+
+struct _GtkRecentActionClass
+{
+ GtkActionClass parent_class;
+
+ /* Padding for future expansion */
+ void (*_gtk_reserved1) (void);
+ void (*_gtk_reserved2) (void);
+ void (*_gtk_reserved3) (void);
+ void (*_gtk_reserved4) (void);
+};
+
+GDK_DEPRECATED_IN_3_10
+GType gtk_recent_action_get_type (void) G_GNUC_CONST;
+GDK_DEPRECATED_IN_3_10
+GtkAction *gtk_recent_action_new (const gchar *name,
+ const gchar *label,
+ const gchar *tooltip,
+ const gchar *stock_id);
+GDK_DEPRECATED_IN_3_10
+GtkAction *gtk_recent_action_new_for_manager (const gchar *name,
+ const gchar *label,
+ const gchar *tooltip,
+ const gchar *stock_id,
+ GtkRecentManager *manager);
+GDK_DEPRECATED_IN_3_10
+gboolean gtk_recent_action_get_show_numbers (GtkRecentAction *action);
+GDK_DEPRECATED_IN_3_10
+void gtk_recent_action_set_show_numbers (GtkRecentAction *action,
+ gboolean show_numbers);
+
+G_END_DECLS
+
+#endif /* __GTK_RECENT_ACTION_H__ */
--- /dev/null
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2000 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#include "config.h"
+
+#define GDK_DISABLE_DEPRECATION_WARNINGS
+
+#include <string.h>
+
+#include "gtkprivate.h"
+#include "gtkstock.h"
+#include "gtkiconfactory.h"
+#include "gtkintl.h"
+
+/**
+ * SECTION:gtkstock
+ * @Short_description:
+Prebuilt common menu/toolbar items and corresponding icons
+ * @Title: Stock Items
+ *
+ * Stock items represent commonly-used menu or toolbar items such as
+ * "Open" or "Exit". Each stock item is identified by a stock ID;
+ * stock IDs are just strings, but macros such as #GTK_STOCK_OPEN are
+ * provided to avoid typing mistakes in the strings.
+ * Applications can register their own stock items in addition to those
+ * built-in to GTK+.
+ *
+ * Each stock ID can be associated with a #GtkStockItem, which contains
+ * the user-visible label, keyboard accelerator, and translation domain
+ * of the menu or toolbar item; and/or with an icon stored in a
+ * #GtkIconFactory. See <link
+ * linkend="gtk3-Themeable-Stock-Images">GtkIconFactory</link> for
+ * more information on stock icons. The connection between a
+ * #GtkStockItem and stock icons is purely conventional (by virtue of
+ * using the same stock ID); it's possible to register a stock item but
+ * no icon, and vice versa. Stock icons may have a RTL variant which gets
+ * used for right-to-left locales.
+ */
+
+static GHashTable *translate_hash = NULL;
+static GHashTable *stock_hash = NULL;
+static void init_stock_hash (void);
+
+/* We use an unused modifier bit to mark stock items which
+ * must be freed when they are removed from the hash table.
+ */
+#define NON_STATIC_MASK (1 << 29)
+
+/* Magic value which is automatically replaced by the primary accel modifier */
+#define PRIMARY_MODIFIER 0xffffffff
+
+typedef struct _GtkStockTranslateFunc GtkStockTranslateFunc;
+struct _GtkStockTranslateFunc
+{
+ GtkTranslateFunc func;
+ gpointer data;
+ GDestroyNotify notify;
+};
+
+static void
+real_add (const GtkStockItem *items,
+ guint n_items,
+ gboolean copy,
+ gboolean replace_primary)
+{
+ int i;
+
+ init_stock_hash ();
+
+ if (n_items == 0)
+ return;
+
+ i = 0;
+ while (i < n_items)
+ {
+ gpointer old_key, old_value;
+ const GtkStockItem *item = &items[i];
+
+ if (replace_primary && item->modifier == PRIMARY_MODIFIER)
+ {
+ item = gtk_stock_item_copy (item);
+ ((GtkStockItem *)item)->modifier = (NON_STATIC_MASK |
+ _gtk_get_primary_accel_mod ());
+ }
+ else
+ {
+ if (item->modifier & NON_STATIC_MASK)
+ {
+ g_warning ("Bit 29 set in stock accelerator.\n");
+ copy = TRUE;
+ }
+
+ if (copy)
+ {
+ item = gtk_stock_item_copy (item);
+ ((GtkStockItem *)item)->modifier |= NON_STATIC_MASK;
+ }
+ }
+
+ if (g_hash_table_lookup_extended (stock_hash, item->stock_id,
+ &old_key, &old_value))
+ {
+ g_hash_table_remove (stock_hash, old_key);
+ if (((GtkStockItem *)old_value)->modifier & NON_STATIC_MASK)
+ gtk_stock_item_free (old_value);
+ }
+
+ g_hash_table_insert (stock_hash,
+ (gchar*)item->stock_id, (GtkStockItem*)item);
+
+ ++i;
+ }
+}
+
+/**
+ * gtk_stock_add:
+ * @items: (array length=n_items): a #GtkStockItem or array of items
+ * @n_items: number of #GtkStockItem in @items
+ *
+ * Registers each of the stock items in @items. If an item already
+ * exists with the same stock ID as one of the @items, the old item
+ * gets replaced. The stock items are copied, so GTK+ does not hold
+ * any pointer into @items and @items can be freed. Use
+ * gtk_stock_add_static() if @items is persistent and GTK+ need not
+ * copy the array.
+ *
+ * Deprecated: 3.10
+ **/
+void
+gtk_stock_add (const GtkStockItem *items,
+ guint n_items)
+{
+ g_return_if_fail (items != NULL);
+
+ real_add (items, n_items, TRUE, FALSE);
+}
+
+/**
+ * gtk_stock_add_static:
+ * @items: (array length=n_items): a #GtkStockItem or array of #GtkStockItem
+ * @n_items: number of items
+ *
+ * Same as gtk_stock_add(), but doesn't copy @items, so
+ * @items must persist until application exit.
+ *
+ * Deprecated: 3.10
+ **/
+void
+gtk_stock_add_static (const GtkStockItem *items,
+ guint n_items)
+{
+ g_return_if_fail (items != NULL);
+
+ real_add (items, n_items, FALSE, FALSE);
+}
+
+/**
+ * gtk_stock_lookup:
+ * @stock_id: a stock item name
+ * @item: (out): stock item to initialize with values
+ *
+ * Fills @item with the registered values for @stock_id, returning %TRUE
+ * if @stock_id was known.
+ *
+ * Return value: %TRUE if @item was initialized
+ *
+ * Deprecated: 3.10
+ **/
+gboolean
+gtk_stock_lookup (const gchar *stock_id,
+ GtkStockItem *item)
+{
+ const GtkStockItem *found;
+
+ g_return_val_if_fail (stock_id != NULL, FALSE);
+ g_return_val_if_fail (item != NULL, FALSE);
+
+ init_stock_hash ();
+
+ found = g_hash_table_lookup (stock_hash, stock_id);
+
+ if (found)
+ {
+ *item = *found;
+ item->modifier &= ~NON_STATIC_MASK;
+ if (item->label)
+ {
+ GtkStockTranslateFunc *translate;
+
+ if (item->translation_domain)
+ translate = (GtkStockTranslateFunc *)
+ g_hash_table_lookup (translate_hash, item->translation_domain);
+ else
+ translate = NULL;
+
+ if (translate != NULL && translate->func != NULL)
+ item->label = (* translate->func) (item->label, translate->data);
+ else
+ item->label = (gchar *) g_dgettext (item->translation_domain, item->label);
+ }
+ }
+
+ return found != NULL;
+}
+
+/**
+ * gtk_stock_list_ids:
+ *
+ * Retrieves a list of all known stock IDs added to a #GtkIconFactory
+ * or registered with gtk_stock_add(). The list must be freed with g_slist_free(),
+ * and each string in the list must be freed with g_free().
+ *
+ * Return value: (element-type utf8) (transfer full): a list of known stock IDs
+ *
+ * Deprecated: 3.10
+ **/
+GSList*
+gtk_stock_list_ids (void)
+{
+ GList *ids;
+ GList *icon_ids;
+ GSList *retval;
+ const gchar *last_id;
+
+ init_stock_hash ();
+
+ ids = g_hash_table_get_keys (stock_hash);
+ icon_ids = _gtk_icon_factory_list_ids ();
+ ids = g_list_concat (ids, icon_ids);
+
+ ids = g_list_sort (ids, (GCompareFunc)strcmp);
+
+ last_id = NULL;
+ retval = NULL;
+ while (ids != NULL)
+ {
+ GList *next;
+
+ next = g_list_next (ids);
+
+ if (last_id && strcmp (ids->data, last_id) == 0)
+ {
+ /* duplicate, ignore */
+ }
+ else
+ {
+ retval = g_slist_prepend (retval, g_strdup (ids->data));
+ last_id = ids->data;
+ }
+
+ g_list_free_1 (ids);
+
+ ids = next;
+ }
+
+ return retval;
+}
+
+/**
+ * gtk_stock_item_copy: (skip)
+ * @item: a #GtkStockItem
+ *
+ * Copies a stock item, mostly useful for language bindings and not in applications.
+ *
+ * Return value: a new #GtkStockItem
+ *
+ * Deprecated: 3.10
+ **/
+GtkStockItem *
+gtk_stock_item_copy (const GtkStockItem *item)
+{
+ GtkStockItem *copy;
+
+ g_return_val_if_fail (item != NULL, NULL);
+
+ copy = g_new (GtkStockItem, 1);
+
+ *copy = *item;
+
+ copy->stock_id = g_strdup (item->stock_id);
+ copy->label = g_strdup (item->label);
+ copy->translation_domain = g_strdup (item->translation_domain);
+
+ return copy;
+}
+
+/**
+ * gtk_stock_item_free:
+ * @item: a #GtkStockItem
+ *
+ * Frees a stock item allocated on the heap, such as one returned by
+ * gtk_stock_item_copy(). Also frees the fields inside the stock item,
+ * if they are not %NULL.
+ *
+ * Deprecated: 3.10
+ **/
+void
+gtk_stock_item_free (GtkStockItem *item)
+{
+ g_return_if_fail (item != NULL);
+
+ g_free ((gchar*)item->stock_id);
+ g_free ((gchar*)item->label);
+ g_free ((gchar*)item->translation_domain);
+
+ g_free (item);
+}
+
+static const GtkStockItem builtin_items [] =
+{
+ /* KEEP IN SYNC with gtkiconfactory.c stock icons, when appropriate */
+
+ { GTK_STOCK_DIALOG_INFO, NC_("Stock label", "Information"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_DIALOG_WARNING, NC_("Stock label", "Warning"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_DIALOG_ERROR, NC_("Stock label", "Error"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_DIALOG_QUESTION, NC_("Stock label", "Question"), 0, 0, GETTEXT_PACKAGE },
+
+ /* FIXME these need accelerators when appropriate, and
+ * need the mnemonics to be rationalized
+ */
+ { GTK_STOCK_ABOUT, NC_("Stock label", "_About"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_ADD, NC_("Stock label", "_Add"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_APPLY, NC_("Stock label", "_Apply"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_BOLD, NC_("Stock label", "_Bold"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_CANCEL, NC_("Stock label", "_Cancel"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_CDROM, NC_("Stock label", "_CD-ROM"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_CLEAR, NC_("Stock label", "_Clear"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_CLOSE, NC_("Stock label", "_Close"), PRIMARY_MODIFIER, 'w', GETTEXT_PACKAGE },
+ { GTK_STOCK_CONNECT, NC_("Stock label", "C_onnect"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_CONVERT, NC_("Stock label", "_Convert"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_COPY, NC_("Stock label", "_Copy"), PRIMARY_MODIFIER, 'c', GETTEXT_PACKAGE },
+ { GTK_STOCK_CUT, NC_("Stock label", "Cu_t"), PRIMARY_MODIFIER, 'x', GETTEXT_PACKAGE },
+ { GTK_STOCK_DELETE, NC_("Stock label", "_Delete"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_DISCARD, NC_("Stock label", "_Discard"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_DISCONNECT, NC_("Stock label", "_Disconnect"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_EXECUTE, NC_("Stock label", "_Execute"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_EDIT, NC_("Stock label", "_Edit"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_FILE, NC_("Stock label", "_File"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_FIND, NC_("Stock label", "_Find"), PRIMARY_MODIFIER, 'f', GETTEXT_PACKAGE },
+ { GTK_STOCK_FIND_AND_REPLACE, NC_("Stock label", "Find and _Replace"), PRIMARY_MODIFIER, 'r', GETTEXT_PACKAGE },
+ { GTK_STOCK_FLOPPY, NC_("Stock label", "_Floppy"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_FULLSCREEN, NC_("Stock label", "_Fullscreen"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_LEAVE_FULLSCREEN, NC_("Stock label", "_Leave Fullscreen"), 0, 0, GETTEXT_PACKAGE },
+ /* This is a navigation label as in "go to the bottom of the page" */
+ { GTK_STOCK_GOTO_BOTTOM, NC_("Stock label, navigation", "_Bottom"), 0, 0, GETTEXT_PACKAGE "-navigation" },
+ /* This is a navigation label as in "go to the first page" */
+ { GTK_STOCK_GOTO_FIRST, NC_("Stock label, navigation", "_First"), 0, 0, GETTEXT_PACKAGE "-navigation" },
+ /* This is a navigation label as in "go to the last page" */
+ { GTK_STOCK_GOTO_LAST, NC_("Stock label, navigation", "_Last"), 0, 0, GETTEXT_PACKAGE "-navigation" },
+ /* This is a navigation label as in "go to the top of the page" */
+ { GTK_STOCK_GOTO_TOP, NC_("Stock label, navigation", "_Top"), 0, 0, GETTEXT_PACKAGE "-navigation" },
+ /* This is a navigation label as in "go back" */
+ { GTK_STOCK_GO_BACK, NC_("Stock label, navigation", "_Back"), 0, 0, GETTEXT_PACKAGE "-navigation" },
+ /* This is a navigation label as in "go down" */
+ { GTK_STOCK_GO_DOWN, NC_("Stock label, navigation", "_Down"), 0, 0, GETTEXT_PACKAGE "-navigation" },
+ /* This is a navigation label as in "go forward" */
+ { GTK_STOCK_GO_FORWARD, NC_("Stock label, navigation", "_Forward"), 0, 0, GETTEXT_PACKAGE "-navigation" },
+ /* This is a navigation label as in "go up" */
+ { GTK_STOCK_GO_UP, NC_("Stock label, navigation", "_Up"), 0, 0, GETTEXT_PACKAGE "-navigation" },
+ { GTK_STOCK_HARDDISK, NC_("Stock label", "_Hard Disk"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_HELP, NC_("Stock label", "_Help"), 0, GDK_KEY_F1, GETTEXT_PACKAGE },
+ { GTK_STOCK_HOME, NC_("Stock label", "_Home"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_INDENT, NC_("Stock label", "Increase Indent"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_UNINDENT, NC_("Stock label", "Decrease Indent"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_INDEX, NC_("Stock label", "_Index"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_INFO, NC_("Stock label", "_Information"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_ITALIC, NC_("Stock label", "_Italic"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_JUMP_TO, NC_("Stock label", "_Jump to"), 0, 0, GETTEXT_PACKAGE },
+ /* This is about text justification, "centered text" */
+ { GTK_STOCK_JUSTIFY_CENTER, NC_("Stock label", "_Center"), 0, 0, GETTEXT_PACKAGE },
+ /* This is about text justification */
+ { GTK_STOCK_JUSTIFY_FILL, NC_("Stock label", "_Fill"), 0, 0, GETTEXT_PACKAGE },
+ /* This is about text justification, "left-justified text" */
+ { GTK_STOCK_JUSTIFY_LEFT, NC_("Stock label", "_Left"), 0, 0, GETTEXT_PACKAGE },
+ /* This is about text justification, "right-justified text" */
+ { GTK_STOCK_JUSTIFY_RIGHT, NC_("Stock label", "_Right"), 0, 0, GETTEXT_PACKAGE },
+
+ /* Media label, as in "fast forward" */
+ { GTK_STOCK_MEDIA_FORWARD, NC_("Stock label, media", "_Forward"), 0, 0, GETTEXT_PACKAGE "-media" },
+ /* Media label, as in "next song" */
+ { GTK_STOCK_MEDIA_NEXT, NC_("Stock label, media", "_Next"), 0, 0, GETTEXT_PACKAGE "-media" },
+ /* Media label, as in "pause music" */
+ { GTK_STOCK_MEDIA_PAUSE, NC_("Stock label, media", "P_ause"), 0, 0, GETTEXT_PACKAGE "-media" },
+ /* Media label, as in "play music" */
+ { GTK_STOCK_MEDIA_PLAY, NC_("Stock label, media", "_Play"), 0, 0, GETTEXT_PACKAGE "-media" },
+ /* Media label, as in "previous song" */
+ { GTK_STOCK_MEDIA_PREVIOUS, NC_("Stock label, media", "Pre_vious"), 0, 0, GETTEXT_PACKAGE "-media" },
+ /* Media label */
+ { GTK_STOCK_MEDIA_RECORD, NC_("Stock label, media", "_Record"), 0, 0, GETTEXT_PACKAGE "-media" },
+ /* Media label */
+ { GTK_STOCK_MEDIA_REWIND, NC_("Stock label, media", "R_ewind"), 0, 0, GETTEXT_PACKAGE "-media" },
+ /* Media label */
+ { GTK_STOCK_MEDIA_STOP, NC_("Stock label, media", "_Stop"), 0, 0, GETTEXT_PACKAGE "-media" },
+ { GTK_STOCK_NETWORK, NC_("Stock label", "_Network"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_NEW, NC_("Stock label", "_New"), PRIMARY_MODIFIER, 'n', GETTEXT_PACKAGE },
+ { GTK_STOCK_NO, NC_("Stock label", "_No"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_OK, NC_("Stock label", "_OK"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_OPEN, NC_("Stock label", "_Open"), PRIMARY_MODIFIER, 'o', GETTEXT_PACKAGE },
+ /* Page orientation */
+ { GTK_STOCK_ORIENTATION_LANDSCAPE, NC_("Stock label", "Landscape"), 0, 0, GETTEXT_PACKAGE },
+ /* Page orientation */
+ { GTK_STOCK_ORIENTATION_PORTRAIT, NC_("Stock label", "Portrait"), 0, 0, GETTEXT_PACKAGE },
+ /* Page orientation */
+ { GTK_STOCK_ORIENTATION_REVERSE_LANDSCAPE, NC_("Stock label", "Reverse landscape"), 0, 0, GETTEXT_PACKAGE },
+ /* Page orientation */
+ { GTK_STOCK_ORIENTATION_REVERSE_PORTRAIT, NC_("Stock label", "Reverse portrait"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_PAGE_SETUP, NC_("Stock label", "Page Set_up"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_PASTE, NC_("Stock label", "_Paste"), PRIMARY_MODIFIER, 'v', GETTEXT_PACKAGE },
+ { GTK_STOCK_PREFERENCES, NC_("Stock label", "_Preferences"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_PRINT, NC_("Stock label", "_Print"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_PRINT_PREVIEW, NC_("Stock label", "Print Pre_view"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_PROPERTIES, NC_("Stock label", "_Properties"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_QUIT, NC_("Stock label", "_Quit"), PRIMARY_MODIFIER, 'q', GETTEXT_PACKAGE },
+ { GTK_STOCK_REDO, NC_("Stock label", "_Redo"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_REFRESH, NC_("Stock label", "_Refresh"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_REMOVE, NC_("Stock label", "_Remove"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_REVERT_TO_SAVED, NC_("Stock label", "_Revert"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_SAVE, NC_("Stock label", "_Save"), PRIMARY_MODIFIER, 's', GETTEXT_PACKAGE },
+ { GTK_STOCK_SAVE_AS, NC_("Stock label", "Save _As"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_SELECT_ALL, NC_("Stock label", "Select _All"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_SELECT_COLOR, NC_("Stock label", "_Color"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_SELECT_FONT, NC_("Stock label", "_Font"), 0, 0, GETTEXT_PACKAGE },
+ /* Sorting direction */
+ { GTK_STOCK_SORT_ASCENDING, NC_("Stock label", "_Ascending"), 0, 0, GETTEXT_PACKAGE },
+ /* Sorting direction */
+ { GTK_STOCK_SORT_DESCENDING, NC_("Stock label", "_Descending"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_SPELL_CHECK, NC_("Stock label", "_Spell Check"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_STOP, NC_("Stock label", "_Stop"), 0, 0, GETTEXT_PACKAGE },
+ /* Font variant */
+ { GTK_STOCK_STRIKETHROUGH, NC_("Stock label", "_Strikethrough"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_UNDELETE, NC_("Stock label", "_Undelete"), 0, 0, GETTEXT_PACKAGE },
+ /* Font variant */
+ { GTK_STOCK_UNDERLINE, NC_("Stock label", "_Underline"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_UNDO, NC_("Stock label", "_Undo"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_YES, NC_("Stock label", "_Yes"), 0, 0, GETTEXT_PACKAGE },
+ /* Zoom */
+ { GTK_STOCK_ZOOM_100, NC_("Stock label", "_Normal Size"), 0, 0, GETTEXT_PACKAGE },
+ /* Zoom */
+ { GTK_STOCK_ZOOM_FIT, NC_("Stock label", "Best _Fit"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_ZOOM_IN, NC_("Stock label", "Zoom _In"), 0, 0, GETTEXT_PACKAGE },
+ { GTK_STOCK_ZOOM_OUT, NC_("Stock label", "Zoom _Out"), 0, 0, GETTEXT_PACKAGE }
+};
+
+/**
+ * gtk_stock_set_translate_func:
+ * @domain: the translation domain for which @func shall be used
+ * @func: a #GtkTranslateFunc
+ * @data: data to pass to @func
+ * @notify: a #GDestroyNotify that is called when @data is
+ * no longer needed
+ *
+ * Sets a function to be used for translating the @label of
+ * a stock item.
+ *
+ * If no function is registered for a translation domain,
+ * g_dgettext() is used.
+ *
+ * The function is used for all stock items whose
+ * @translation_domain matches @domain. Note that it is possible
+ * to use strings different from the actual gettext translation domain
+ * of your application for this, as long as your #GtkTranslateFunc uses
+ * the correct domain when calling dgettext(). This can be useful, e.g.
+ * when dealing with message contexts:
+ *
+ * |[
+ * GtkStockItem items[] = {
+ * { MY_ITEM1, NC_("odd items", "Item 1"), 0, 0, "odd-item-domain" },
+ * { MY_ITEM2, NC_("even items", "Item 2"), 0, 0, "even-item-domain" },
+ * };
+ *
+ * gchar *
+ * my_translate_func (const gchar *msgid,
+ * gpointer data)
+ * {
+ * gchar *msgctxt = data;
+ *
+ * return (gchar*)g_dpgettext2 (GETTEXT_PACKAGE, msgctxt, msgid);
+ * }
+ *
+ * /* ... */
+ *
+ * gtk_stock_add (items, G_N_ELEMENTS (items));
+ * gtk_stock_set_translate_func ("odd-item-domain", my_translate_func, "odd items");
+ * gtk_stock_set_translate_func ("even-item-domain", my_translate_func, "even items");
+ * ]|
+ *
+ * Since: 2.8
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_stock_set_translate_func (const gchar *domain,
+ GtkTranslateFunc func,
+ gpointer data,
+ GDestroyNotify notify)
+{
+ GtkStockTranslateFunc *translate;
+ gchar *domainname;
+
+ domainname = g_strdup (domain);
+
+ translate = (GtkStockTranslateFunc *)
+ g_hash_table_lookup (translate_hash, domainname);
+
+ if (translate)
+ {
+ if (translate->notify)
+ (* translate->notify) (translate->data);
+ }
+ else
+ translate = g_new0 (GtkStockTranslateFunc, 1);
+
+ translate->func = func;
+ translate->data = data;
+ translate->notify = notify;
+
+ g_hash_table_insert (translate_hash, domainname, translate);
+}
+
+static gchar *
+sgettext_swapped (const gchar *msgid,
+ gpointer data)
+{
+ gchar *msgctxt = data;
+
+ return (gchar *)g_dpgettext2 (GETTEXT_PACKAGE, msgctxt, msgid);
+}
+
+static void
+init_stock_hash (void)
+{
+ if (stock_hash == NULL)
+ {
+ stock_hash = g_hash_table_new (g_str_hash, g_str_equal);
+
+ real_add (builtin_items, G_N_ELEMENTS (builtin_items), FALSE, TRUE);
+ }
+
+ if (translate_hash == NULL)
+ {
+ translate_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, NULL);
+
+ gtk_stock_set_translate_func (GETTEXT_PACKAGE,
+ sgettext_swapped,
+ "Stock label",
+ NULL);
+ gtk_stock_set_translate_func (GETTEXT_PACKAGE "-navigation",
+ sgettext_swapped,
+ "Stock label, navigation",
+ NULL);
+ gtk_stock_set_translate_func (GETTEXT_PACKAGE "-media",
+ sgettext_swapped,
+ "Stock label, media",
+ NULL);
+ }
+}
--- /dev/null
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2000 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __GTK_STOCK_H__
+#define __GTK_STOCK_H__
+
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#include <gdk/gdk.h>
+
+G_BEGIN_DECLS
+
+/*
+ * GtkTranslateFunc:
+ * @path: The id of the message. In #GtkActionGroup this will be a label
+ * or tooltip from a #GtkActionEntry.
+ * @func_data: user data passed in when registering the function
+ *
+ * The function used to translate messages in e.g. #GtkIconFactory
+ * and #GtkActionGroup.
+ *
+ * Returns: the translated message
+ *
+ * Deprecated: 3.10
+ */
+typedef gchar * (*GtkTranslateFunc) (const gchar *path,
+ gpointer func_data);
+
+typedef struct _GtkStockItem GtkStockItem;
+
+struct _GtkStockItem
+{
+ gchar *stock_id;
+ gchar *label;
+ GdkModifierType modifier;
+ guint keyval;
+ gchar *translation_domain;
+};
+
+GDK_DEPRECATED_IN_3_10
+void gtk_stock_add (const GtkStockItem *items,
+ guint n_items);
+GDK_DEPRECATED_IN_3_10
+void gtk_stock_add_static (const GtkStockItem *items,
+ guint n_items);
+GDK_DEPRECATED_IN_3_10
+gboolean gtk_stock_lookup (const gchar *stock_id,
+ GtkStockItem *item);
+
+/* Should free the list (and free each string in it also).
+ * This function is only useful for GUI builders and such.
+ */
+GDK_DEPRECATED_IN_3_10
+GSList* gtk_stock_list_ids (void);
+
+GDK_DEPRECATED_IN_3_10
+GtkStockItem *gtk_stock_item_copy (const GtkStockItem *item);
+GDK_DEPRECATED_IN_3_10
+void gtk_stock_item_free (GtkStockItem *item);
+
+GDK_DEPRECATED_IN_3_10
+void gtk_stock_set_translate_func (const gchar *domain,
+ GtkTranslateFunc func,
+ gpointer data,
+ GDestroyNotify notify);
+
+/* the following type exists just so we can get deprecation warnings */
+#ifndef GDK_DISABLE_DEPRECATION_WARNINGS
+#if GDK_VERSION_MIN_REQUIRED >= GDK_VERSION_3_10
+G_DEPRECATED
+#endif
+#endif
+typedef char * GtkStock;
+
+/* Stock IDs (not all are stock items; some are images only) */
+/**
+ * GTK_STOCK_ABOUT:
+ *
+ * The "About" item.
+ * <inlinegraphic fileref="help-about.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.6
+ *
+ * Deprecated: 3.10: Use named icon "help-about" or the label "_About".
+ */
+#define GTK_STOCK_ABOUT ((GtkStock)"gtk-about")
+
+/**
+ * GTK_STOCK_ADD:
+ *
+ * The "Add" item.
+ * <inlinegraphic fileref="list-add.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "list-add" or the label "_Add".
+ */
+#define GTK_STOCK_ADD ((GtkStock)"gtk-add")
+
+/**
+ * GTK_STOCK_APPLY:
+ *
+ * The "Apply" item.
+ * <inlinegraphic fileref="gtk-apply.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Do not use an icon. Use label "_Apply".
+ */
+#define GTK_STOCK_APPLY ((GtkStock)"gtk-apply")
+
+/**
+ * GTK_STOCK_BOLD:
+ *
+ * The "Bold" item.
+ * <inlinegraphic fileref="format-text-bold.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "format-text-bold".
+ */
+#define GTK_STOCK_BOLD ((GtkStock)"gtk-bold")
+
+/**
+ * GTK_STOCK_CANCEL:
+ *
+ * The "Cancel" item.
+ * <inlinegraphic fileref="gtk-cancel.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Do not use an icon. Use label "_Cancel".
+ */
+#define GTK_STOCK_CANCEL ((GtkStock)"gtk-cancel")
+
+/**
+ * GTK_STOCK_CAPS_LOCK_WARNING:
+ *
+ * The "Caps Lock Warning" icon.
+ * <inlinegraphic fileref="gtk-caps-lock-warning.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.16
+ *
+ * Deprecated: 3.10: Use named icon "dialog-warning-symbolic".
+ */
+#define GTK_STOCK_CAPS_LOCK_WARNING ((GtkStock)"gtk-caps-lock-warning")
+
+/**
+ * GTK_STOCK_CDROM:
+ *
+ * The "CD-Rom" item.
+ * <inlinegraphic fileref="media-optical.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "media-optical".
+ */
+#define GTK_STOCK_CDROM ((GtkStock)"gtk-cdrom")
+
+/**
+ * GTK_STOCK_CLEAR:
+ *
+ * The "Clear" item.
+ * <inlinegraphic fileref="edit-clear.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "edit-clear".
+ */
+#define GTK_STOCK_CLEAR ((GtkStock)"gtk-clear")
+
+/**
+ * GTK_STOCK_CLOSE:
+ *
+ * The "Close" item.
+ * <inlinegraphic fileref="window-close.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "window-close" or the label "_Close".
+ */
+#define GTK_STOCK_CLOSE ((GtkStock)"gtk-close")
+
+/**
+ * GTK_STOCK_COLOR_PICKER:
+ *
+ * The "Color Picker" item.
+ * <inlinegraphic fileref="gtk-color-picker.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.2
+ *
+ * Deprecated: 3.10
+ */
+#define GTK_STOCK_COLOR_PICKER ((GtkStock)"gtk-color-picker")
+
+/**
+ * GTK_STOCK_CONNECT:
+ *
+ * The "Connect" icon.
+ * <inlinegraphic fileref="gtk-connect.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.6
+ *
+ * Deprecated: 3.10
+ */
+#define GTK_STOCK_CONNECT ((GtkStock)"gtk-connect")
+
+/**
+ * GTK_STOCK_CONVERT:
+ *
+ * The "Convert" item.
+ * <inlinegraphic fileref="gtk-convert.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10
+ */
+#define GTK_STOCK_CONVERT ((GtkStock)"gtk-convert")
+
+/**
+ * GTK_STOCK_COPY:
+ *
+ * The "Copy" item.
+ * <inlinegraphic fileref="edit-copy.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Do not use an icon. Use label "_Copy".
+ */
+#define GTK_STOCK_COPY ((GtkStock)"gtk-copy")
+
+/**
+ * GTK_STOCK_CUT:
+ *
+ * The "Cut" item.
+ * <inlinegraphic fileref="edit-cut.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Do not use an icon. Use label "Cu_t".
+ */
+#define GTK_STOCK_CUT ((GtkStock)"gtk-cut")
+
+/**
+ * GTK_STOCK_DELETE:
+ *
+ * The "Delete" item.
+ * <inlinegraphic fileref="edit-delete.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Do not use an icon. Use label "_Delete".
+ */
+#define GTK_STOCK_DELETE ((GtkStock)"gtk-delete")
+
+/**
+ * GTK_STOCK_DIALOG_AUTHENTICATION:
+ *
+ * The "Authentication" item.
+ * <inlinegraphic fileref="dialog-password.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10: Use named icon "dialog-password".
+ */
+#define GTK_STOCK_DIALOG_AUTHENTICATION ((GtkStock)"gtk-dialog-authentication")
+
+/**
+ * GTK_STOCK_DIALOG_INFO:
+ *
+ * The "Information" item.
+ * <inlinegraphic fileref="dialog-information.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "dialog-information".
+ */
+#define GTK_STOCK_DIALOG_INFO ((GtkStock)"gtk-dialog-info")
+
+/**
+ * GTK_STOCK_DIALOG_WARNING:
+ *
+ * The "Warning" item.
+ * <inlinegraphic fileref="dialog-warning.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "dialog-warning".
+ */
+#define GTK_STOCK_DIALOG_WARNING ((GtkStock)"gtk-dialog-warning")
+
+/**
+ * GTK_STOCK_DIALOG_ERROR:
+ *
+ * The "Error" item.
+ * <inlinegraphic fileref="dialog-error.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "dialog-error".
+ */
+#define GTK_STOCK_DIALOG_ERROR ((GtkStock)"gtk-dialog-error")
+
+/**
+ * GTK_STOCK_DIALOG_QUESTION:
+ *
+ * The "Question" item.
+ * <inlinegraphic fileref="dialog-question.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "dialog-question".
+ */
+#define GTK_STOCK_DIALOG_QUESTION ((GtkStock)"gtk-dialog-question")
+
+/**
+ * GTK_STOCK_DIRECTORY:
+ *
+ * The "Directory" icon.
+ * <inlinegraphic fileref="folder.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.6
+ *
+ * Deprecated: 3.10: Use named icon "folder".
+ */
+#define GTK_STOCK_DIRECTORY ((GtkStock)"gtk-directory")
+
+/**
+ * GTK_STOCK_DISCARD:
+ *
+ * The "Discard" item.
+ *
+ * Since: 2.12
+ *
+ * Deprecated: 3.10
+ */
+#define GTK_STOCK_DISCARD ((GtkStock)"gtk-discard")
+
+/**
+ * GTK_STOCK_DISCONNECT:
+ *
+ * The "Disconnect" icon.
+ * <inlinegraphic fileref="gtk-disconnect.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.6
+ *
+ * Deprecated: 3.10
+ */
+#define GTK_STOCK_DISCONNECT ((GtkStock)"gtk-disconnect")
+
+/**
+ * GTK_STOCK_DND:
+ *
+ * The "Drag-And-Drop" icon.
+ * <inlinegraphic fileref="gtk-dnd.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10
+ */
+#define GTK_STOCK_DND ((GtkStock)"gtk-dnd")
+
+/**
+ * GTK_STOCK_DND_MULTIPLE:
+ *
+ * The "Drag-And-Drop multiple" icon.
+ * <inlinegraphic fileref="gtk-dnd-multiple.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10
+ */
+#define GTK_STOCK_DND_MULTIPLE ((GtkStock)"gtk-dnd-multiple")
+
+/**
+ * GTK_STOCK_EDIT:
+ *
+ * The "Edit" item.
+ * <inlinegraphic fileref="gtk-edit.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.6
+ *
+ * Deprecated: 3.10
+ */
+#define GTK_STOCK_EDIT ((GtkStock)"gtk-edit")
+
+/**
+ * GTK_STOCK_EXECUTE:
+ *
+ * The "Execute" item.
+ * <inlinegraphic fileref="system-run.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "system-run".
+ */
+#define GTK_STOCK_EXECUTE ((GtkStock)"gtk-execute")
+
+/**
+ * GTK_STOCK_FILE:
+ *
+ * The "File" item.
+ * <inlinegraphic fileref="text-x-generic.png" format="PNG"></inlinegraphic>
+ *
+ * Since 3.0, this item has a label, before it only had an icon.
+ *
+ * Since: 2.6
+ *
+ * Deprecated: 3.10: Use named icon "text-x-generic".
+ */
+#define GTK_STOCK_FILE ((GtkStock)"gtk-file")
+
+/**
+ * GTK_STOCK_FIND:
+ *
+ * The "Find" item.
+ * <inlinegraphic fileref="edit-find.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "edit-find".
+ */
+#define GTK_STOCK_FIND ((GtkStock)"gtk-find")
+
+/**
+ * GTK_STOCK_FIND_AND_REPLACE:
+ *
+ * The "Find and Replace" item.
+ * <inlinegraphic fileref="edit-find-replace.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "edit-find-replace".
+ */
+#define GTK_STOCK_FIND_AND_REPLACE ((GtkStock)"gtk-find-and-replace")
+
+/**
+ * GTK_STOCK_FLOPPY:
+ *
+ * The "Floppy" item.
+ * <inlinegraphic fileref="media-floppy.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10
+ */
+#define GTK_STOCK_FLOPPY ((GtkStock)"gtk-floppy")
+
+/**
+ * GTK_STOCK_FULLSCREEN:
+ *
+ * The "Fullscreen" item.
+ * <inlinegraphic fileref="view-fullscreen.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.8
+ *
+ * Deprecated: 3.10: Use named icon "view-fullscreen".
+ */
+#define GTK_STOCK_FULLSCREEN ((GtkStock)"gtk-fullscreen")
+
+/**
+ * GTK_STOCK_GOTO_BOTTOM:
+ *
+ * The "Bottom" item.
+ * <inlinegraphic fileref="go-bottom.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "go-bottom".
+ */
+#define GTK_STOCK_GOTO_BOTTOM ((GtkStock)"gtk-goto-bottom")
+
+/**
+ * GTK_STOCK_GOTO_FIRST:
+ *
+ * The "First" item.
+ * <inlinegraphic fileref="go-first-ltr.png" format="PNG"></inlinegraphic>
+ * RTL variant
+ * <inlinegraphic fileref="go-first-rtl.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "go-first".
+ */
+#define GTK_STOCK_GOTO_FIRST ((GtkStock)"gtk-goto-first")
+
+/**
+ * GTK_STOCK_GOTO_LAST:
+ *
+ * The "Last" item.
+ * <inlinegraphic fileref="go-last-ltr.png" format="PNG"></inlinegraphic>
+ * RTL variant
+ * <inlinegraphic fileref="go-last-rtl.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "go-last".
+ */
+#define GTK_STOCK_GOTO_LAST ((GtkStock)"gtk-goto-last")
+
+/**
+ * GTK_STOCK_GOTO_TOP:
+ *
+ * The "Top" item.
+ * <inlinegraphic fileref="go-top.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "go-top".
+ */
+#define GTK_STOCK_GOTO_TOP ((GtkStock)"gtk-goto-top")
+
+/**
+ * GTK_STOCK_GO_BACK:
+ *
+ * The "Back" item.
+ * <inlinegraphic fileref="go-previous-ltr.png" format="PNG"></inlinegraphic>
+ * RTL variant
+ * <inlinegraphic fileref="go-previous-rtl.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "go-previous".
+*/
+#define GTK_STOCK_GO_BACK ((GtkStock)"gtk-go-back")
+
+/**
+ * GTK_STOCK_GO_DOWN:
+ *
+ * The "Down" item.
+ * <inlinegraphic fileref="go-down.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "go-down".
+ */
+#define GTK_STOCK_GO_DOWN ((GtkStock)"gtk-go-down")
+
+/**
+ * GTK_STOCK_GO_FORWARD:
+ *
+ * The "Forward" item.
+ * <inlinegraphic fileref="go-next-ltr.png" format="PNG"></inlinegraphic>
+ * RTL variant
+ * <inlinegraphic fileref="go-next-rtl.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "go-next".
+ */
+#define GTK_STOCK_GO_FORWARD ((GtkStock)"gtk-go-forward")
+
+/**
+ * GTK_STOCK_GO_UP:
+ *
+ * The "Up" item.
+ * <inlinegraphic fileref="go-up.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "go-up".
+ */
+#define GTK_STOCK_GO_UP ((GtkStock)"gtk-go-up")
+
+/**
+ * GTK_STOCK_HARDDISK:
+ *
+ * The "Harddisk" item.
+ * <inlinegraphic fileref="drive-harddisk.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10: Use named icon "drive-harddisk".
+ */
+#define GTK_STOCK_HARDDISK ((GtkStock)"gtk-harddisk")
+
+/**
+ * GTK_STOCK_HELP:
+ *
+ * The "Help" item.
+ * <inlinegraphic fileref="help-contents.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "help-browser".
+ */
+#define GTK_STOCK_HELP ((GtkStock)"gtk-help")
+
+/**
+ * GTK_STOCK_HOME:
+ *
+ * The "Home" item.
+ * <inlinegraphic fileref="go-home.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "go-home".
+ */
+#define GTK_STOCK_HOME ((GtkStock)"gtk-home")
+
+/**
+ * GTK_STOCK_INDEX:
+ *
+ * The "Index" item.
+ * <inlinegraphic fileref="gtk-index.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10
+ */
+#define GTK_STOCK_INDEX ((GtkStock)"gtk-index")
+
+/**
+ * GTK_STOCK_INDENT:
+ *
+ * The "Indent" item.
+ * <inlinegraphic fileref="format-indent-more-ltr.png" format="PNG"></inlinegraphic>
+ * RTL variant
+ * <inlinegraphic fileref="format-indent-more-rtl.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10: Use named icon "format-indent-more".
+ */
+#define GTK_STOCK_INDENT ((GtkStock)"gtk-indent")
+
+/**
+ * GTK_STOCK_INFO:
+ *
+ * The "Info" item.
+ * <inlinegraphic fileref="dialog-information.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.8
+ *
+ * Deprecated: 3.10: Use named icon "dialog-information".
+ */
+#define GTK_STOCK_INFO ((GtkStock)"gtk-info")
+
+/**
+ * GTK_STOCK_ITALIC:
+ *
+ * The "Italic" item.
+ * <inlinegraphic fileref="format-text-italic.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "format-text-italic".
+ */
+#define GTK_STOCK_ITALIC ((GtkStock)"gtk-italic")
+
+/**
+ * GTK_STOCK_JUMP_TO:
+ *
+ * The "Jump to" item.
+ * <inlinegraphic fileref="go-jump-ltr.png" format="PNG"></inlinegraphic>
+ * RTL-variant
+ * <inlinegraphic fileref="go-jump-rtl.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "go-jump".
+ */
+#define GTK_STOCK_JUMP_TO ((GtkStock)"gtk-jump-to")
+
+/**
+ * GTK_STOCK_JUSTIFY_CENTER:
+ *
+ * The "Center" item.
+ * <inlinegraphic fileref="format-justify-center.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "format-justify-center".
+ */
+#define GTK_STOCK_JUSTIFY_CENTER ((GtkStock)"gtk-justify-center")
+
+/**
+ * GTK_STOCK_JUSTIFY_FILL:
+ *
+ * The "Fill" item.
+ * <inlinegraphic fileref="format-justify-fill.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "format-justify-fill".
+ */
+#define GTK_STOCK_JUSTIFY_FILL ((GtkStock)"gtk-justify-fill")
+
+/**
+ * GTK_STOCK_JUSTIFY_LEFT:
+ *
+ * The "Left" item.
+ * <inlinegraphic fileref="format-justify-left.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "format-justify-left".
+ */
+#define GTK_STOCK_JUSTIFY_LEFT ((GtkStock)"gtk-justify-left")
+
+/**
+ * GTK_STOCK_JUSTIFY_RIGHT:
+ *
+ * The "Right" item.
+ * <inlinegraphic fileref="format-justify-right.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "format-justify-right".
+ */
+#define GTK_STOCK_JUSTIFY_RIGHT ((GtkStock)"gtk-justify-right")
+
+/**
+ * GTK_STOCK_LEAVE_FULLSCREEN:
+ *
+ * The "Leave Fullscreen" item.
+ * <inlinegraphic fileref="view-restore.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.8
+ *
+ * Deprecated: 3.10: Use named icon "view-restore".
+ */
+#define GTK_STOCK_LEAVE_FULLSCREEN ((GtkStock)"gtk-leave-fullscreen")
+
+/**
+ * GTK_STOCK_MISSING_IMAGE:
+ *
+ * The "Missing image" icon.
+ * <inlinegraphic fileref="image-missing.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "image-missing".
+ */
+#define GTK_STOCK_MISSING_IMAGE ((GtkStock)"gtk-missing-image")
+
+/**
+ * GTK_STOCK_MEDIA_FORWARD:
+ *
+ * The "Media Forward" item.
+ * <inlinegraphic fileref="media-seek-forward-ltr.png" format="PNG"></inlinegraphic>
+ * RTL variant
+ * <inlinegraphic fileref="media-seek-forward-rtl.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.6
+ *
+ * Deprecated: 3.10: Use named icon "media-seek-forward" or the label "_Forward".
+ */
+#define GTK_STOCK_MEDIA_FORWARD ((GtkStock)"gtk-media-forward")
+
+/**
+ * GTK_STOCK_MEDIA_NEXT:
+ *
+ * The "Media Next" item.
+ * <inlinegraphic fileref="media-skip-forward-ltr.png" format="PNG"></inlinegraphic>
+ * RTL variant
+ * <inlinegraphic fileref="media-skip-forward-rtl.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.6
+ *
+ * Deprecated: 3.10: Use named icon "media-skip-forward" or the label "_Next".
+ */
+#define GTK_STOCK_MEDIA_NEXT ((GtkStock)"gtk-media-next")
+
+/**
+ * GTK_STOCK_MEDIA_PAUSE:
+ *
+ * The "Media Pause" item.
+ * <inlinegraphic fileref="media-playback-pause.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.6
+ *
+ * Deprecated: 3.10: Use named icon "media-playback-pause" or the label "P_ause".
+ */
+#define GTK_STOCK_MEDIA_PAUSE ((GtkStock)"gtk-media-pause")
+
+/**
+ * GTK_STOCK_MEDIA_PLAY:
+ *
+ * The "Media Play" item.
+ * <inlinegraphic fileref="media-playback-start-ltr.png" format="PNG"></inlinegraphic>
+ * RTL variant
+ * <inlinegraphic fileref="media-playback-start-rtl.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.6
+ *
+ * Deprecated: 3.10: Use named icon "media-playback-start" or the label "_Play".
+ */
+#define GTK_STOCK_MEDIA_PLAY ((GtkStock)"gtk-media-play")
+
+/**
+ * GTK_STOCK_MEDIA_PREVIOUS:
+ *
+ * The "Media Previous" item.
+ * <inlinegraphic fileref="media-skip-backward-ltr.png" format="PNG"></inlinegraphic>
+ * RTL variant
+ * <inlinegraphic fileref="media-skip-backward-rtl.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.6
+ *
+ * Deprecated: 3.10: Use named icon "media-skip-backward" or the label "Pre_vious".
+ */
+#define GTK_STOCK_MEDIA_PREVIOUS ((GtkStock)"gtk-media-previous")
+
+/**
+ * GTK_STOCK_MEDIA_RECORD:
+ *
+ * The "Media Record" item.
+ * <inlinegraphic fileref="media-record.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.6
+ *
+ * Deprecated: 3.10: Use named icon "media-record" or the label "_Record".
+ */
+#define GTK_STOCK_MEDIA_RECORD ((GtkStock)"gtk-media-record")
+
+/**
+ * GTK_STOCK_MEDIA_REWIND:
+ *
+ * The "Media Rewind" item.
+ * <inlinegraphic fileref="media-seek-backward-ltr.png" format="PNG"></inlinegraphic>
+ * RTL variant
+ * <inlinegraphic fileref="media-seek-backward-rtl.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.6
+ *
+ * Deprecated: 3.10: Use named icon "media-seek-backward" or the label "R_ewind".
+ */
+#define GTK_STOCK_MEDIA_REWIND ((GtkStock)"gtk-media-rewind")
+
+/**
+ * GTK_STOCK_MEDIA_STOP:
+ *
+ * The "Media Stop" item.
+ * <inlinegraphic fileref="media-playback-stop.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.6
+ *
+ * Deprecated: 3.10: Use named icon "media-playback-stop" or the label "_Stop".
+ */
+#define GTK_STOCK_MEDIA_STOP ((GtkStock)"gtk-media-stop")
+
+/**
+ * GTK_STOCK_NETWORK:
+ *
+ * The "Network" item.
+ * <inlinegraphic fileref="network-idle.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10: Use named icon "network-workgroup".
+ */
+#define GTK_STOCK_NETWORK ((GtkStock)"gtk-network")
+
+/**
+ * GTK_STOCK_NEW:
+ *
+ * The "New" item.
+ * <inlinegraphic fileref="document-new.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "document-new" or the label "_New".
+ */
+#define GTK_STOCK_NEW ((GtkStock)"gtk-new")
+
+/**
+ * GTK_STOCK_NO:
+ *
+ * The "No" item.
+ * <inlinegraphic fileref="gtk-no.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10
+ */
+#define GTK_STOCK_NO ((GtkStock)"gtk-no")
+
+/**
+ * GTK_STOCK_OK:
+ *
+ * The "OK" item.
+ * <inlinegraphic fileref="gtk-ok.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Do not use an icon. Use label "_OK".
+ */
+#define GTK_STOCK_OK ((GtkStock)"gtk-ok")
+
+/**
+ * GTK_STOCK_OPEN:
+ *
+ * The "Open" item.
+ * <inlinegraphic fileref="document-open.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "document-open" or the label "_Open".
+ */
+#define GTK_STOCK_OPEN ((GtkStock)"gtk-open")
+
+/**
+ * GTK_STOCK_ORIENTATION_PORTRAIT:
+ *
+ * The "Portrait Orientation" item.
+ * <inlinegraphic fileref="gtk-orientation-portrait.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.10
+ *
+ * Deprecated: 3.10
+ */
+#define GTK_STOCK_ORIENTATION_PORTRAIT ((GtkStock)"gtk-orientation-portrait")
+
+/**
+ * GTK_STOCK_ORIENTATION_LANDSCAPE:
+ *
+ * The "Landscape Orientation" item.
+ * <inlinegraphic fileref="gtk-orientation-landscape.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.10
+ *
+ * Deprecated: 3.10
+ */
+#define GTK_STOCK_ORIENTATION_LANDSCAPE ((GtkStock)"gtk-orientation-landscape")
+
+/**
+ * GTK_STOCK_ORIENTATION_REVERSE_LANDSCAPE:
+ *
+ * The "Reverse Landscape Orientation" item.
+ * <inlinegraphic fileref="gtk-orientation-reverse-landscape.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.10
+ *
+ * Deprecated: 3.10
+ */
+#define GTK_STOCK_ORIENTATION_REVERSE_LANDSCAPE ((GtkStock)"gtk-orientation-reverse-landscape")
+
+/**
+ * GTK_STOCK_ORIENTATION_REVERSE_PORTRAIT:
+ *
+ * The "Reverse Portrait Orientation" item.
+ * <inlinegraphic fileref="gtk-orientation-reverse-portrait.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.10
+ *
+ * Deprecated: 3.10
+ */
+#define GTK_STOCK_ORIENTATION_REVERSE_PORTRAIT ((GtkStock)"gtk-orientation-reverse-portrait")
+
+/**
+ * GTK_STOCK_PAGE_SETUP:
+ *
+ * The "Page Setup" item.
+ * <inlinegraphic fileref="gtk-page-setup.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.14
+ *
+ * Deprecated: 3.10: Use named icon "document-page-setup" or the label "Page Set_up".
+ */
+#define GTK_STOCK_PAGE_SETUP ((GtkStock)"gtk-page-setup")
+
+/**
+ * GTK_STOCK_PASTE:
+ *
+ * The "Paste" item.
+ * <inlinegraphic fileref="edit-paste.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Do not use an icon. Use label "_Paste".
+ */
+#define GTK_STOCK_PASTE ((GtkStock)"gtk-paste")
+
+/**
+ * GTK_STOCK_PREFERENCES:
+ *
+ * The "Preferences" item.
+ * <inlinegraphic fileref="gtk-preferences.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "preferences-system" or the label "_Preferences".
+ */
+#define GTK_STOCK_PREFERENCES ((GtkStock)"gtk-preferences")
+
+/**
+ * GTK_STOCK_PRINT:
+ *
+ * The "Print" item.
+ * <inlinegraphic fileref="document-print.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "document-print" or the label "_Print".
+ */
+#define GTK_STOCK_PRINT ((GtkStock)"gtk-print")
+
+/**
+ * GTK_STOCK_PRINT_ERROR:
+ *
+ * The "Print Error" icon.
+ * <inlinegraphic fileref="printer-error.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.14
+ *
+ * Deprecated: 3.10: Use named icon "printer-error".
+ */
+#define GTK_STOCK_PRINT_ERROR ((GtkStock)"gtk-print-error")
+
+/**
+ * GTK_STOCK_PRINT_PAUSED:
+ *
+ * The "Print Paused" icon.
+ * <inlinegraphic fileref="printer-paused.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.14
+ *
+ * Deprecated: 3.10
+ */
+#define GTK_STOCK_PRINT_PAUSED ((GtkStock)"gtk-print-paused")
+
+/**
+ * GTK_STOCK_PRINT_PREVIEW:
+ *
+ * The "Print Preview" item.
+ * <inlinegraphic fileref="document-print-preview.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use label "Pre_view".
+ */
+#define GTK_STOCK_PRINT_PREVIEW ((GtkStock)"gtk-print-preview")
+
+/**
+ * GTK_STOCK_PRINT_REPORT:
+ *
+ * The "Print Report" icon.
+ * <inlinegraphic fileref="printer-info.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.14
+ *
+ * Deprecated: 3.10
+ */
+#define GTK_STOCK_PRINT_REPORT ((GtkStock)"gtk-print-report")
+
+
+/**
+ * GTK_STOCK_PRINT_WARNING:
+ *
+ * The "Print Warning" icon.
+ * <inlinegraphic fileref="printer-warning.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.14
+ *
+ * Deprecated: 3.10
+ */
+#define GTK_STOCK_PRINT_WARNING ((GtkStock)"gtk-print-warning")
+
+/**
+ * GTK_STOCK_PROPERTIES:
+ *
+ * The "Properties" item.
+ * <inlinegraphic fileref="document-properties.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "document-properties" or the label "_Properties".
+ */
+#define GTK_STOCK_PROPERTIES ((GtkStock)"gtk-properties")
+
+/**
+ * GTK_STOCK_QUIT:
+ *
+ * The "Quit" item.
+ * <inlinegraphic fileref="application-exit.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "application-exit" or the label "_Quit".
+ */
+#define GTK_STOCK_QUIT ((GtkStock)"gtk-quit")
+
+/**
+ * GTK_STOCK_REDO:
+ *
+ * The "Redo" item.
+ * <inlinegraphic fileref="edit-redo-ltr.png" format="PNG"></inlinegraphic>
+ * RTL variant
+ * <inlinegraphic fileref="edit-redo-rtl.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "edit-redo" or the label "_Redo".
+ */
+#define GTK_STOCK_REDO ((GtkStock)"gtk-redo")
+
+/**
+ * GTK_STOCK_REFRESH:
+ *
+ * The "Refresh" item.
+ * <inlinegraphic fileref="view-refresh.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "view-refresh" or the label "_Refresh".
+ */
+#define GTK_STOCK_REFRESH ((GtkStock)"gtk-refresh")
+
+/**
+ * GTK_STOCK_REMOVE:
+ *
+ * The "Remove" item.
+ * <inlinegraphic fileref="list-remove.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "list-remove" or the label "_Remove".
+ */
+#define GTK_STOCK_REMOVE ((GtkStock)"gtk-remove")
+
+/**
+ * GTK_STOCK_REVERT_TO_SAVED:
+ *
+ * The "Revert" item.
+ * <inlinegraphic fileref="document-revert-ltr.png" format="PNG"></inlinegraphic>
+ * RTL variant
+ * <inlinegraphic fileref="document-revert-rtl.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "document-revert" or the label "_Revert".
+ */
+#define GTK_STOCK_REVERT_TO_SAVED ((GtkStock)"gtk-revert-to-saved")
+
+/**
+ * GTK_STOCK_SAVE:
+ *
+ * The "Save" item.
+ * <inlinegraphic fileref="document-save.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "document-save" or the label "_Save".
+ */
+#define GTK_STOCK_SAVE ((GtkStock)"gtk-save")
+
+/**
+ * GTK_STOCK_SAVE_AS:
+ *
+ * The "Save As" item.
+ * <inlinegraphic fileref="document-save-as.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "document-save-as" or the label "Save _As".
+ */
+#define GTK_STOCK_SAVE_AS ((GtkStock)"gtk-save-as")
+
+/**
+ * GTK_STOCK_SELECT_ALL:
+ *
+ * The "Select All" item.
+ * <inlinegraphic fileref="edit-select-all.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.10
+ *
+ * Deprecated: 3.10: Use named icon "edit-select-all" or the label "Select _All".
+ */
+#define GTK_STOCK_SELECT_ALL ((GtkStock)"gtk-select-all")
+
+/**
+ * GTK_STOCK_SELECT_COLOR:
+ *
+ * The "Color" item.
+ * <inlinegraphic fileref="gtk-select-color.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10
+ */
+#define GTK_STOCK_SELECT_COLOR ((GtkStock)"gtk-select-color")
+
+/**
+ * GTK_STOCK_SELECT_FONT:
+ *
+ * The "Font" item.
+ * <inlinegraphic fileref="gtk-font.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10
+ */
+#define GTK_STOCK_SELECT_FONT ((GtkStock)"gtk-select-font")
+
+/**
+ * GTK_STOCK_SORT_ASCENDING:
+ *
+ * The "Ascending" item.
+ * <inlinegraphic fileref="view-sort-ascending.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "view-sort-ascending".
+ */
+#define GTK_STOCK_SORT_ASCENDING ((GtkStock)"gtk-sort-ascending")
+
+/**
+ * GTK_STOCK_SORT_DESCENDING:
+ *
+ * The "Descending" item.
+ * <inlinegraphic fileref="view-sort-descending.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "view-sort-descending".
+ */
+#define GTK_STOCK_SORT_DESCENDING ((GtkStock)"gtk-sort-descending")
+
+/**
+ * GTK_STOCK_SPELL_CHECK:
+ *
+ * The "Spell Check" item.
+ * <inlinegraphic fileref="tools-check-spelling.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "tools-check-spelling".
+ */
+#define GTK_STOCK_SPELL_CHECK ((GtkStock)"gtk-spell-check")
+
+/**
+ * GTK_STOCK_STOP:
+ *
+ * The "Stop" item.
+ * <inlinegraphic fileref="process-stop.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "process-stop" or the label "_Stop".
+ */
+#define GTK_STOCK_STOP ((GtkStock)"gtk-stop")
+
+/**
+ * GTK_STOCK_STRIKETHROUGH:
+ *
+ * The "Strikethrough" item.
+ * <inlinegraphic fileref="format-text-strikethrough.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "format-text-strikethrough" or the label "_Strikethrough".
+ */
+#define GTK_STOCK_STRIKETHROUGH ((GtkStock)"gtk-strikethrough")
+
+/**
+ * GTK_STOCK_UNDELETE:
+ *
+ * The "Undelete" item.
+ * <inlinegraphic fileref="gtk-undelete-ltr.png" format="PNG"></inlinegraphic>
+ * RTL variant
+ * <inlinegraphic fileref="gtk-undelete-rtl.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10
+ */
+#define GTK_STOCK_UNDELETE ((GtkStock)"gtk-undelete")
+
+/**
+ * GTK_STOCK_UNDERLINE:
+ *
+ * The "Underline" item.
+ * <inlinegraphic fileref="format-text-underline.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "format-text-underline" or the label "_Underline".
+ */
+#define GTK_STOCK_UNDERLINE ((GtkStock)"gtk-underline")
+
+/**
+ * GTK_STOCK_UNDO:
+ *
+ * The "Undo" item.
+ * <inlinegraphic fileref="edit-undo-ltr.png" format="PNG"></inlinegraphic>
+ * RTL variant
+ * <inlinegraphic fileref="edit-undo-rtl.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "edit-undo" or the label "_Undo".
+ */
+#define GTK_STOCK_UNDO ((GtkStock)"gtk-undo")
+
+/**
+ * GTK_STOCK_UNINDENT:
+ *
+ * The "Unindent" item.
+ * <inlinegraphic fileref="format-indent-less-ltr.png" format="PNG"></inlinegraphic>
+ * RTL variant
+ * <inlinegraphic fileref="format-indent-less-rtl.png" format="PNG"></inlinegraphic>
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10: Use named icon "format-indent-less".
+ */
+#define GTK_STOCK_UNINDENT ((GtkStock)"gtk-unindent")
+
+/**
+ * GTK_STOCK_YES:
+ *
+ * The "Yes" item.
+ * <inlinegraphic fileref="gtk-yes.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10
+ */
+#define GTK_STOCK_YES ((GtkStock)"gtk-yes")
+
+/**
+ * GTK_STOCK_ZOOM_100:
+ *
+ * The "Zoom 100%" item.
+ * <inlinegraphic fileref="zoom-original.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "zoom-original" or the label "_Normal Size".
+ */
+#define GTK_STOCK_ZOOM_100 ((GtkStock)"gtk-zoom-100")
+
+/**
+ * GTK_STOCK_ZOOM_FIT:
+ *
+ * The "Zoom to Fit" item.
+ * <inlinegraphic fileref="zoom-fit-best.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "zoom-fit-best" or the label "Best _Fit".
+ */
+#define GTK_STOCK_ZOOM_FIT ((GtkStock)"gtk-zoom-fit")
+
+/**
+ * GTK_STOCK_ZOOM_IN:
+ *
+ * The "Zoom In" item.
+ * <inlinegraphic fileref="zoom-in.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "zoom-in" or the label "Zoom _In".
+ */
+#define GTK_STOCK_ZOOM_IN ((GtkStock)"gtk-zoom-in")
+
+/**
+ * GTK_STOCK_ZOOM_OUT:
+ *
+ * The "Zoom Out" item.
+ * <inlinegraphic fileref="zoom-out.png" format="PNG"></inlinegraphic>
+ *
+ * Deprecated: 3.10: Use named icon "zoom-out" or the label "Zoom _Out".
+ */
+#define GTK_STOCK_ZOOM_OUT ((GtkStock)"gtk-zoom-out")
+
+G_END_DECLS
+
+#endif /* __GTK_STOCK_H__ */
--- /dev/null
+/*
+ * GTK - The GIMP Toolkit
+ * Copyright (C) 1998, 1999 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Author: James Henstridge <james@daa.com.au>
+ *
+ * Modified by the GTK+ Team and others 2003. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#include "config.h"
+
+#define GDK_DISABLE_DEPRECATION_WARNINGS
+
+#include "gtkintl.h"
+#include "gtktoggleaction.h"
+#include "gtktoggletoolbutton.h"
+#include "gtktogglebutton.h"
+#include "gtkcheckmenuitem.h"
+#include "gtkprivate.h"
+
+
+/**
+ * SECTION:gtktoggleaction
+ * @Short_description: An action which can be toggled between two states
+ * @Title: GtkToggleAction
+ *
+ * A #GtkToggleAction corresponds roughly to a #GtkCheckMenuItem. It has an
+ * "active" state specifying whether the action has been checked or not.
+ */
+
+struct _GtkToggleActionPrivate
+{
+ guint active : 1;
+ guint draw_as_radio : 1;
+};
+
+enum
+{
+ TOGGLED,
+ LAST_SIGNAL
+};
+
+enum {
+ PROP_0,
+ PROP_DRAW_AS_RADIO,
+ PROP_ACTIVE
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GtkToggleAction, gtk_toggle_action, GTK_TYPE_ACTION)
+
+static void gtk_toggle_action_activate (GtkAction *action);
+static void set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static GtkWidget *create_menu_item (GtkAction *action);
+
+
+static GObjectClass *parent_class = NULL;
+static guint action_signals[LAST_SIGNAL] = { 0 };
+
+static void
+gtk_toggle_action_class_init (GtkToggleActionClass *klass)
+{
+ GObjectClass *gobject_class;
+ GtkActionClass *action_class;
+
+ parent_class = g_type_class_peek_parent (klass);
+ gobject_class = G_OBJECT_CLASS (klass);
+ action_class = GTK_ACTION_CLASS (klass);
+
+ gobject_class->set_property = set_property;
+ gobject_class->get_property = get_property;
+
+ action_class->activate = gtk_toggle_action_activate;
+
+ action_class->menu_item_type = GTK_TYPE_CHECK_MENU_ITEM;
+ action_class->toolbar_item_type = GTK_TYPE_TOGGLE_TOOL_BUTTON;
+
+ action_class->create_menu_item = create_menu_item;
+
+ klass->toggled = NULL;
+
+ /**
+ * GtkToggleAction:draw-as-radio:
+ *
+ * Whether the proxies for this action look like radio action proxies.
+ *
+ * This is an appearance property and thus only applies if
+ * #GtkActivatable:use-action-appearance is %TRUE.
+ *
+ * Deprecated: 3.10
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_DRAW_AS_RADIO,
+ g_param_spec_boolean ("draw-as-radio",
+ P_("Create the same proxies as a radio action"),
+ P_("Whether the proxies for this action look like radio action proxies"),
+ FALSE,
+ GTK_PARAM_READWRITE));
+
+ /**
+ * GtkToggleAction:active:
+ *
+ * Whether the toggle action should be active.
+ *
+ * Since: 2.10
+ *
+ * Deprecated: 3.10
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_ACTIVE,
+ g_param_spec_boolean ("active",
+ P_("Active"),
+ P_("Whether the toggle action should be active"),
+ FALSE,
+ GTK_PARAM_READWRITE));
+ /**
+ * GtkToggleAction::toggled:
+ * @toggleaction: the object which received the signal.
+ *
+ * Should be connected if you wish to perform an action
+ * whenever the #GtkToggleAction state is changed.
+ *
+ * Deprecated: 3.10
+ */
+ action_signals[TOGGLED] =
+ g_signal_new (I_("toggled"),
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GtkToggleActionClass, toggled),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+}
+
+static void
+gtk_toggle_action_init (GtkToggleAction *action)
+{
+ action->private_data = gtk_toggle_action_get_instance_private (action);
+ action->private_data->active = FALSE;
+ action->private_data->draw_as_radio = FALSE;
+}
+
+/**
+ * gtk_toggle_action_new:
+ * @name: A unique name for the action
+ * @label: (allow-none): The label displayed in menu items and on buttons,
+ * or %NULL
+ * @tooltip: (allow-none): A tooltip for the action, or %NULL
+ * @stock_id: (allow-none): The stock icon to display in widgets representing
+ * the action, or %NULL
+ *
+ * Creates a new #GtkToggleAction object. To add the action to
+ * a #GtkActionGroup and set the accelerator for the action,
+ * call gtk_action_group_add_action_with_accel().
+ *
+ * Return value: a new #GtkToggleAction
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+GtkToggleAction *
+gtk_toggle_action_new (const gchar *name,
+ const gchar *label,
+ const gchar *tooltip,
+ const gchar *stock_id)
+{
+ g_return_val_if_fail (name != NULL, NULL);
+
+ return g_object_new (GTK_TYPE_TOGGLE_ACTION,
+ "name", name,
+ "label", label,
+ "tooltip", tooltip,
+ "stock-id", stock_id,
+ NULL);
+}
+
+static void
+get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GtkToggleAction *action = GTK_TOGGLE_ACTION (object);
+
+ switch (prop_id)
+ {
+ case PROP_DRAW_AS_RADIO:
+ g_value_set_boolean (value, gtk_toggle_action_get_draw_as_radio (action));
+ break;
+ case PROP_ACTIVE:
+ g_value_set_boolean (value, gtk_toggle_action_get_active (action));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GtkToggleAction *action = GTK_TOGGLE_ACTION (object);
+
+ switch (prop_id)
+ {
+ case PROP_DRAW_AS_RADIO:
+ gtk_toggle_action_set_draw_as_radio (action, g_value_get_boolean (value));
+ break;
+ case PROP_ACTIVE:
+ gtk_toggle_action_set_active (action, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gtk_toggle_action_activate (GtkAction *action)
+{
+ GtkToggleAction *toggle_action;
+
+ g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
+
+ toggle_action = GTK_TOGGLE_ACTION (action);
+
+ toggle_action->private_data->active = !toggle_action->private_data->active;
+
+ g_object_notify (G_OBJECT (action), "active");
+
+ gtk_toggle_action_toggled (toggle_action);
+}
+
+/**
+ * gtk_toggle_action_toggled:
+ * @action: the action object
+ *
+ * Emits the "toggled" signal on the toggle action.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_toggle_action_toggled (GtkToggleAction *action)
+{
+ g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
+
+ g_signal_emit (action, action_signals[TOGGLED], 0);
+}
+
+/**
+ * gtk_toggle_action_set_active:
+ * @action: the action object
+ * @is_active: whether the action should be checked or not
+ *
+ * Sets the checked state on the toggle action.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_toggle_action_set_active (GtkToggleAction *action,
+ gboolean is_active)
+{
+ g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
+
+ is_active = is_active != FALSE;
+
+ if (action->private_data->active != is_active)
+ _gtk_action_emit_activate (GTK_ACTION (action));
+}
+
+/**
+ * gtk_toggle_action_get_active:
+ * @action: the action object
+ *
+ * Returns the checked state of the toggle action.
+ *
+ * Returns: the checked state of the toggle action
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+gboolean
+gtk_toggle_action_get_active (GtkToggleAction *action)
+{
+ g_return_val_if_fail (GTK_IS_TOGGLE_ACTION (action), FALSE);
+
+ return action->private_data->active;
+}
+
+
+/**
+ * gtk_toggle_action_set_draw_as_radio:
+ * @action: the action object
+ * @draw_as_radio: whether the action should have proxies like a radio
+ * action
+ *
+ * Sets whether the action should have proxies like a radio action.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+void
+gtk_toggle_action_set_draw_as_radio (GtkToggleAction *action,
+ gboolean draw_as_radio)
+{
+ g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
+
+ draw_as_radio = draw_as_radio != FALSE;
+
+ if (action->private_data->draw_as_radio != draw_as_radio)
+ {
+ action->private_data->draw_as_radio = draw_as_radio;
+
+ g_object_notify (G_OBJECT (action), "draw-as-radio");
+ }
+}
+
+/**
+ * gtk_toggle_action_get_draw_as_radio:
+ * @action: the action object
+ *
+ * Returns whether the action should have proxies like a radio action.
+ *
+ * Returns: whether the action should have proxies like a radio action.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+gboolean
+gtk_toggle_action_get_draw_as_radio (GtkToggleAction *action)
+{
+ g_return_val_if_fail (GTK_IS_TOGGLE_ACTION (action), FALSE);
+
+ return action->private_data->draw_as_radio;
+}
+
+static GtkWidget *
+create_menu_item (GtkAction *action)
+{
+ GtkToggleAction *toggle_action = GTK_TOGGLE_ACTION (action);
+
+ return g_object_new (GTK_TYPE_CHECK_MENU_ITEM,
+ "draw-as-radio", toggle_action->private_data->draw_as_radio,
+ NULL);
+}
+
+
+/* Private */
+
+/*
+ * _gtk_toggle_action_set_active:
+ * @toggle_action: a #GtkToggleAction
+ * @is_active: whether the action is active or not
+ *
+ * Sets the #GtkToggleAction:active property directly. This function does
+ * not emit signals or notifications: it is left to the caller to do so.
+ *
+ * Deprecated: 3.10
+ */
+void
+_gtk_toggle_action_set_active (GtkToggleAction *toggle_action,
+ gboolean is_active)
+{
+ GtkToggleActionPrivate *priv = toggle_action->private_data;
+
+ priv->active = is_active;
+}
--- /dev/null
+/*
+ * GTK - The GIMP Toolkit
+ * Copyright (C) 1998, 1999 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Author: James Henstridge <james@daa.com.au>
+ *
+ * Modified by the GTK+ Team and others 2003. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __GTK_TOGGLE_ACTION_H__
+#define __GTK_TOGGLE_ACTION_H__
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#include <gtk/deprecated/gtkaction.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_TOGGLE_ACTION (gtk_toggle_action_get_type ())
+#define GTK_TOGGLE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TOGGLE_ACTION, GtkToggleAction))
+#define GTK_TOGGLE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TOGGLE_ACTION, GtkToggleActionClass))
+#define GTK_IS_TOGGLE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TOGGLE_ACTION))
+#define GTK_IS_TOGGLE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TOGGLE_ACTION))
+#define GTK_TOGGLE_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_TOGGLE_ACTION, GtkToggleActionClass))
+
+typedef struct _GtkToggleAction GtkToggleAction;
+typedef struct _GtkToggleActionPrivate GtkToggleActionPrivate;
+typedef struct _GtkToggleActionClass GtkToggleActionClass;
+
+struct _GtkToggleAction
+{
+ GtkAction parent;
+
+ /*< private >*/
+ GtkToggleActionPrivate *private_data;
+};
+
+struct _GtkToggleActionClass
+{
+ GtkActionClass parent_class;
+
+ void (* toggled) (GtkToggleAction *action);
+
+ /* Padding for future expansion */
+ void (*_gtk_reserved1) (void);
+ void (*_gtk_reserved2) (void);
+ void (*_gtk_reserved3) (void);
+ void (*_gtk_reserved4) (void);
+};
+
+GDK_DEPRECATED_IN_3_10
+GType gtk_toggle_action_get_type (void) G_GNUC_CONST;
+GDK_DEPRECATED_IN_3_10
+GtkToggleAction *gtk_toggle_action_new (const gchar *name,
+ const gchar *label,
+ const gchar *tooltip,
+ const gchar *stock_id);
+GDK_DEPRECATED_IN_3_10
+void gtk_toggle_action_toggled (GtkToggleAction *action);
+GDK_DEPRECATED_IN_3_10
+void gtk_toggle_action_set_active (GtkToggleAction *action,
+ gboolean is_active);
+GDK_DEPRECATED_IN_3_10
+gboolean gtk_toggle_action_get_active (GtkToggleAction *action);
+GDK_DEPRECATED_IN_3_10
+void gtk_toggle_action_set_draw_as_radio (GtkToggleAction *action,
+ gboolean draw_as_radio);
+GDK_DEPRECATED_IN_3_10
+gboolean gtk_toggle_action_get_draw_as_radio (GtkToggleAction *action);
+
+/* private */
+void _gtk_toggle_action_set_active (GtkToggleAction *toggle_action,
+ gboolean is_active);
+
+
+G_END_DECLS
+
+#endif /* __GTK_TOGGLE_ACTION_H__ */
--- /dev/null
+/*
+ * GTK - The GIMP Toolkit
+ * Copyright (C) 1998, 1999 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Author: James Henstridge <james@daa.com.au>
+ *
+ * Modified by the GTK+ Team and others 2003. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#include "config.h"
+
+#define GDK_DISABLE_DEPRECATION_WARNINGS
+
+#include <string.h>
+#include "gtkaccellabel.h"
+#include "gtkactivatable.h"
+#include "gtkbuildable.h"
+#include "gtkimagemenuitem.h"
+#include "gtkintl.h"
+#include "gtkmarshalers.h"
+#include "gtkmenu.h"
+#include "gtkmenushellprivate.h"
+#include "gtkmenubar.h"
+#include "gtkmenutoolbutton.h"
+#include "gtkseparatormenuitem.h"
+#include "gtkseparatortoolitem.h"
+#include "gtktoolbar.h"
+#include "gtkwindow.h"
+#include "gtkprivate.h"
+
+#include "gtkuimanager.h"
+#include "deprecated/gtktearoffmenuitem.h"
+
+/**
+ * SECTION:gtkuimanager
+ * @Short_description: Constructing menus and toolbars from an XML description
+ * @Title: GtkUIManager
+ * @See_also:#GtkBuilder
+ *
+ * A #GtkUIManager constructs a user interface (menus and toolbars) from
+ * one or more UI definitions, which reference actions from one or more
+ * action groups.
+ *
+ * <refsect2 id="XML-UI">
+ * <title>UI Definitions</title>
+ * <para>
+ * The UI definitions are specified in an XML format which can be
+ * roughly described by the following DTD.
+ *
+ * <note><para>
+ * Do not confuse the GtkUIManager UI Definitions described here with
+ * the similarly named <link linkend="BUILDER-UI">GtkBuilder UI
+ * Definitions</link>.
+ * </para></note>
+ *
+ * <programlisting>
+ * <![CDATA[
+ * <!ELEMENT ui (menubar|toolbar|popup|accelerator)* >
+ * <!ELEMENT menubar (menuitem|separator|placeholder|menu)* >
+ * <!ELEMENT menu (menuitem|separator|placeholder|menu)* >
+ * <!ELEMENT popup (menuitem|separator|placeholder|menu)* >
+ * <!ELEMENT toolbar (toolitem|separator|placeholder)* >
+ * <!ELEMENT placeholder (menuitem|toolitem|separator|placeholder|menu)* >
+ * <!ELEMENT menuitem EMPTY >
+ * <!ELEMENT toolitem (menu?) >
+ * <!ELEMENT separator EMPTY >
+ * <!ELEMENT accelerator EMPTY >
+ * <!ATTLIST menubar name #IMPLIED
+ * action #IMPLIED >
+ * <!ATTLIST toolbar name #IMPLIED
+ * action #IMPLIED >
+ * <!ATTLIST popup name #IMPLIED
+ * action #IMPLIED
+ * accelerators (true|false) #IMPLIED >
+ * <!ATTLIST placeholder name #IMPLIED
+ * action #IMPLIED >
+ * <!ATTLIST separator name #IMPLIED
+ * action #IMPLIED
+ * expand (true|false) #IMPLIED >
+ * <!ATTLIST menu name #IMPLIED
+ * action #REQUIRED
+ * position (top|bot) #IMPLIED >
+ * <!ATTLIST menuitem name #IMPLIED
+ * action #REQUIRED
+ * position (top|bot) #IMPLIED
+ * always-show-image (true|false) #IMPLIED >
+ * <!ATTLIST toolitem name #IMPLIED
+ * action #REQUIRED
+ * position (top|bot) #IMPLIED >
+ * <!ATTLIST accelerator name #IMPLIED
+ * action #REQUIRED >
+ * ]]>
+ * </programlisting>
+ * There are some additional restrictions beyond those specified in the
+ * DTD, e.g. every toolitem must have a toolbar in its anchestry and
+ * every menuitem must have a menubar or popup in its anchestry. Since
+ * a #GMarkup parser is used to parse the UI description, it must not only
+ * be valid XML, but valid #GMarkup.
+ *
+ * If a name is not specified, it defaults to the action. If an action is
+ * not specified either, the element name is used. The name and action
+ * attributes must not contain '/' characters after parsing (since that
+ * would mess up path lookup) and must be usable as XML attributes when
+ * enclosed in doublequotes, thus they must not '"' characters or references
+ * to the " entity.
+ *
+ * <example>
+ * <title>A UI definition</title>
+ * <programlisting><![CDATA[
+ * <ui>
+ * <menubar>
+ * <menu name="FileMenu" action="FileMenuAction">
+ * <menuitem name="New" action="New2Action" />
+ * <placeholder name="FileMenuAdditions" />
+ * </menu>
+ * <menu name="JustifyMenu" action="JustifyMenuAction">
+ * <menuitem name="Left" action="justify-left"/>
+ * <menuitem name="Centre" action="justify-center"/>
+ * <menuitem name="Right" action="justify-right"/>
+ * <menuitem name="Fill" action="justify-fill"/>
+ * </menu>
+ * </menubar>
+ * <toolbar action="toolbar1">
+ * <placeholder name="JustifyToolItems">
+ * <separator/>
+ * <toolitem name="Left" action="justify-left"/>
+ * <toolitem name="Centre" action="justify-center"/>
+ * <toolitem name="Right" action="justify-right"/>
+ * <toolitem name="Fill" action="justify-fill"/>
+ * <separator/>
+ * </placeholder>
+ * </toolbar>
+ * </ui>
+ * ]]></programlisting>
+ * </example>
+ *
+ * The constructed widget hierarchy is very similar to the element tree
+ * of the XML, with the exception that placeholders are merged into their
+ * parents. The correspondence of XML elements to widgets should be
+ * almost obvious:
+ * <variablelist>
+ * <varlistentry>
+ * <term>menubar</term>
+ * <listitem><para>a #GtkMenuBar</para></listitem>
+ * </varlistentry>
+ * <varlistentry>
+ * <term>toolbar</term>
+ * <listitem><para>a #GtkToolbar</para></listitem>
+ * </varlistentry>
+ * <varlistentry>
+ * <term>popup</term>
+ * <listitem><para>a toplevel #GtkMenu</para></listitem>
+ * </varlistentry>
+ * <varlistentry>
+ * <term>menu</term>
+ * <listitem><para>a #GtkMenu attached to a menuitem</para></listitem>
+ * </varlistentry>
+ * <varlistentry>
+ * <term>menuitem</term>
+ * <listitem><para>a #GtkMenuItem subclass, the exact type depends on the
+ * action</para></listitem>
+ * </varlistentry>
+ * <varlistentry>
+ * <term>toolitem</term>
+ * <listitem><para>a #GtkToolItem subclass, the exact type depends on the
+ * action. Note that toolitem elements may contain a menu element, but only
+ * if their associated action specifies a #GtkMenuToolButton as proxy.</para></listitem>
+ * </varlistentry>
+ * <varlistentry>
+ * <term>separator</term>
+ * <listitem><para>a #GtkSeparatorMenuItem or
+ * #GtkSeparatorToolItem</para></listitem>
+ * </varlistentry>
+ * <varlistentry>
+ * <term>accelerator</term>
+ * <listitem><para>a keyboard accelerator</para></listitem>
+ * </varlistentry>
+ * </variablelist>
+ *
+ * The "position" attribute determines where a constructed widget is positioned
+ * wrt. to its siblings in the partially constructed tree. If it is
+ * "top", the widget is prepended, otherwise it is appended.
+ * </para>
+ * </refsect2>
+ * <refsect2 id="UI-Merging">
+ * <title>UI Merging</title>
+ * <para>
+ * The most remarkable feature of #GtkUIManager is that it can overlay a set
+ * of menuitems and toolitems over another one, and demerge them later.
+ *
+ * Merging is done based on the names of the XML elements. Each element is
+ * identified by a path which consists of the names of its anchestors, separated
+ * by slashes. For example, the menuitem named "Left" in the example above
+ * has the path <literal>/ui/menubar/JustifyMenu/Left</literal> and the
+ * toolitem with the same name has path
+ * <literal>/ui/toolbar1/JustifyToolItems/Left</literal>.
+ * </para>
+ * </refsect2>
+ * <refsect2>
+ * <title>Accelerators</title>
+ * <para>
+ * Every action has an accelerator path. Accelerators are installed together with
+ * menuitem proxies, but they can also be explicitly added with <accelerator>
+ * elements in the UI definition. This makes it possible to have accelerators for
+ * actions even if they have no visible proxies.
+ * </para>
+ * </refsect2>
+ * <refsect2 id="Smart-Separators">
+ * <title>Smart Separators</title>
+ * <para>
+ * The separators created by #GtkUIManager are "smart", i.e. they do not show up
+ * in the UI unless they end up between two visible menu or tool items. Separators
+ * which are located at the very beginning or end of the menu or toolbar
+ * containing them, or multiple separators next to each other, are hidden. This
+ * is a useful feature, since the merging of UI elements from multiple sources
+ * can make it hard or impossible to determine in advance whether a separator
+ * will end up in such an unfortunate position.
+ *
+ * For separators in toolbars, you can set <literal>expand="true"</literal> to
+ * turn them from a small, visible separator to an expanding, invisible one.
+ * Toolitems following an expanding separator are effectively right-aligned.
+ * </para>
+ * </refsect2>
+ * <refsect2>
+ * <title>Empty Menus</title>
+ * <para>
+ * Submenus pose similar problems to separators inconnection with merging. It is
+ * impossible to know in advance whether they will end up empty after merging.
+ * #GtkUIManager offers two ways to treat empty submenus:
+ * <itemizedlist>
+ * <listitem>
+ * <para>make them disappear by hiding the menu item they're attached to</para>
+ * </listitem>
+ * <listitem>
+ * <para>add an insensitive "Empty" item</para>
+ * </listitem>
+ * </itemizedlist>
+ * The behaviour is chosen based on the "hide_if_empty" property of the action
+ * to which the submenu is associated.
+ * </para>
+ * </refsect2>
+ * <refsect2 id="GtkUIManager-BUILDER-UI">
+ * <title>GtkUIManager as GtkBuildable</title>
+ * <para>
+ * The GtkUIManager implementation of the GtkBuildable interface accepts
+ * GtkActionGroup objects as <child> elements in UI definitions.
+ *
+ * A GtkUIManager UI definition as described above can be embedded in
+ * an GtkUIManager <object> element in a GtkBuilder UI definition.
+ *
+ * The widgets that are constructed by a GtkUIManager can be embedded in
+ * other parts of the constructed user interface with the help of the
+ * "constructor" attribute. See the example below.
+ *
+ * <example>
+ * <title>An embedded GtkUIManager UI definition</title>
+ * <programlisting><![CDATA[
+ * <object class="GtkUIManager" id="uiman">
+ * <child>
+ * <object class="GtkActionGroup" id="actiongroup">
+ * <child>
+ * <object class="GtkAction" id="file">
+ * <property name="label">_File</property>
+ * </object>
+ * </child>
+ * </object>
+ * </child>
+ * <ui>
+ * <menubar name="menubar1">
+ * <menu action="file">
+ * </menu>
+ * </menubar>
+ * </ui>
+ * </object>
+ * <object class="GtkWindow" id="main-window">
+ * <child>
+ * <object class="GtkMenuBar" id="menubar1" constructor="uiman"/>
+ * </child>
+ * </object>
+ * ]]></programlisting>
+ * </example>
+ * </para>
+ * </refsect2>
+ */
+
+
+#undef DEBUG_UI_MANAGER
+
+typedef enum
+{
+ NODE_TYPE_UNDECIDED,
+ NODE_TYPE_ROOT,
+ NODE_TYPE_MENUBAR,
+ NODE_TYPE_MENU,
+ NODE_TYPE_TOOLBAR,
+ NODE_TYPE_MENU_PLACEHOLDER,
+ NODE_TYPE_TOOLBAR_PLACEHOLDER,
+ NODE_TYPE_POPUP,
+ NODE_TYPE_MENUITEM,
+ NODE_TYPE_TOOLITEM,
+ NODE_TYPE_SEPARATOR,
+ NODE_TYPE_ACCELERATOR
+} NodeType;
+
+typedef struct _Node Node;
+
+struct _Node {
+ NodeType type;
+
+ gchar *name;
+
+ GQuark action_name;
+ GtkAction *action;
+ GtkWidget *proxy;
+ GtkWidget *extra; /* second separator for placeholders */
+
+ GList *uifiles;
+
+ guint dirty : 1;
+ guint expand : 1; /* used for separators */
+ guint popup_accels : 1;
+ guint always_show_image_set : 1; /* used for menu items */
+ guint always_show_image : 1; /* used for menu items */
+};
+
+
+struct _GtkUIManagerPrivate
+{
+ GtkAccelGroup *accel_group;
+
+ GNode *root_node;
+ GList *action_groups;
+
+ guint last_merge_id;
+
+ guint update_tag;
+
+ gboolean add_tearoffs;
+};
+
+#define NODE_INFO(node) ((Node *)node->data)
+
+typedef struct _NodeUIReference NodeUIReference;
+
+struct _NodeUIReference
+{
+ guint merge_id;
+ GQuark action_quark;
+};
+
+static void gtk_ui_manager_finalize (GObject *object);
+static void gtk_ui_manager_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gtk_ui_manager_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static GtkWidget * gtk_ui_manager_real_get_widget (GtkUIManager *manager,
+ const gchar *path);
+static GtkAction * gtk_ui_manager_real_get_action (GtkUIManager *manager,
+ const gchar *path);
+static void queue_update (GtkUIManager *manager);
+static void dirty_all_nodes (GtkUIManager *manager);
+static void mark_node_dirty (GNode *node);
+static GNode * get_child_node (GtkUIManager *manager,
+ GNode *parent,
+ GNode *sibling,
+ const gchar *childname,
+ gint childname_length,
+ NodeType node_type,
+ gboolean create,
+ gboolean top);
+static GNode * get_node (GtkUIManager *manager,
+ const gchar *path,
+ NodeType node_type,
+ gboolean create);
+static gboolean free_node (GNode *node);
+static void node_prepend_ui_reference (GNode *node,
+ guint merge_id,
+ GQuark action_quark);
+static void node_remove_ui_reference (GNode *node,
+ guint merge_id);
+
+/* GtkBuildable */
+static void gtk_ui_manager_buildable_init (GtkBuildableIface *iface);
+static void gtk_ui_manager_buildable_add_child (GtkBuildable *buildable,
+ GtkBuilder *builder,
+ GObject *child,
+ const gchar *type);
+static GObject* gtk_ui_manager_buildable_construct_child (GtkBuildable *buildable,
+ GtkBuilder *builder,
+ const gchar *name);
+static gboolean gtk_ui_manager_buildable_custom_tag_start (GtkBuildable *buildable,
+ GtkBuilder *builder,
+ GObject *child,
+ const gchar *tagname,
+ GMarkupParser *parser,
+ gpointer *data);
+static void gtk_ui_manager_buildable_custom_tag_end (GtkBuildable *buildable,
+ GtkBuilder *builder,
+ GObject *child,
+ const gchar *tagname,
+ gpointer *data);
+static void gtk_ui_manager_do_set_add_tearoffs (GtkUIManager *manager,
+ gboolean add_tearoffs);
+
+
+
+enum
+{
+ ADD_WIDGET,
+ ACTIONS_CHANGED,
+ CONNECT_PROXY,
+ DISCONNECT_PROXY,
+ PRE_ACTIVATE,
+ POST_ACTIVATE,
+ LAST_SIGNAL
+};
+
+enum
+{
+ PROP_0,
+ PROP_ADD_TEAROFFS,
+ PROP_UI
+};
+
+static guint ui_manager_signals[LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE_WITH_CODE (GtkUIManager, gtk_ui_manager, G_TYPE_OBJECT,
+ G_ADD_PRIVATE (GtkUIManager)
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
+ gtk_ui_manager_buildable_init))
+
+static void
+gtk_ui_manager_class_init (GtkUIManagerClass *klass)
+{
+ GObjectClass *gobject_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+
+ gobject_class->finalize = gtk_ui_manager_finalize;
+ gobject_class->set_property = gtk_ui_manager_set_property;
+ gobject_class->get_property = gtk_ui_manager_get_property;
+ klass->get_widget = gtk_ui_manager_real_get_widget;
+ klass->get_action = gtk_ui_manager_real_get_action;
+
+ /**
+ * GtkUIManager:add-tearoffs:
+ *
+ * The "add-tearoffs" property controls whether generated menus
+ * have tearoff menu items.
+ *
+ * Note that this only affects regular menus. Generated popup
+ * menus never have tearoff menu items.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.4: Tearoff menus are deprecated and should not
+ * be used in newly written code.
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_ADD_TEAROFFS,
+ g_param_spec_boolean ("add-tearoffs",
+ P_("Add tearoffs to menus"),
+ P_("Whether tearoff menu items should be added to menus"),
+ FALSE,
+ GTK_PARAM_READWRITE | G_PARAM_DEPRECATED));
+
+ g_object_class_install_property (gobject_class,
+ PROP_UI,
+ g_param_spec_string ("ui",
+ P_("Merged UI definition"),
+ P_("An XML string describing the merged UI"),
+ "<ui>\n</ui>\n",
+ GTK_PARAM_READABLE));
+
+
+ /**
+ * GtkUIManager::add-widget:
+ * @manager: a #GtkUIManager
+ * @widget: the added widget
+ *
+ * The ::add-widget signal is emitted for each generated menubar and toolbar.
+ * It is not emitted for generated popup menus, which can be obtained by
+ * gtk_ui_manager_get_widget().
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+ ui_manager_signals[ADD_WIDGET] =
+ g_signal_new (I_("add-widget"),
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
+ G_STRUCT_OFFSET (GtkUIManagerClass, add_widget),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ GTK_TYPE_WIDGET);
+
+ /**
+ * GtkUIManager::actions-changed:
+ * @manager: a #GtkUIManager
+ *
+ * The ::actions-changed signal is emitted whenever the set of actions
+ * changes.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+ ui_manager_signals[ACTIONS_CHANGED] =
+ g_signal_new (I_("actions-changed"),
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
+ G_STRUCT_OFFSET (GtkUIManagerClass, actions_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ /**
+ * GtkUIManager::connect-proxy:
+ * @manager: the ui manager
+ * @action: the action
+ * @proxy: the proxy
+ *
+ * The ::connect-proxy signal is emitted after connecting a proxy to
+ * an action in the group.
+ *
+ * This is intended for simple customizations for which a custom action
+ * class would be too clumsy, e.g. showing tooltips for menuitems in the
+ * statusbar.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+ ui_manager_signals[CONNECT_PROXY] =
+ g_signal_new (I_("connect-proxy"),
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
+ G_STRUCT_OFFSET (GtkUIManagerClass, connect_proxy),
+ NULL, NULL,
+ _gtk_marshal_VOID__OBJECT_OBJECT,
+ G_TYPE_NONE, 2,
+ GTK_TYPE_ACTION,
+ GTK_TYPE_WIDGET);
+
+ /**
+ * GtkUIManager::disconnect-proxy:
+ * @manager: the ui manager
+ * @action: the action
+ * @proxy: the proxy
+ *
+ * The ::disconnect-proxy signal is emitted after disconnecting a proxy
+ * from an action in the group.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+ ui_manager_signals[DISCONNECT_PROXY] =
+ g_signal_new (I_("disconnect-proxy"),
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
+ G_STRUCT_OFFSET (GtkUIManagerClass, disconnect_proxy),
+ NULL, NULL,
+ _gtk_marshal_VOID__OBJECT_OBJECT,
+ G_TYPE_NONE, 2,
+ GTK_TYPE_ACTION,
+ GTK_TYPE_WIDGET);
+
+ /**
+ * GtkUIManager::pre-activate:
+ * @manager: the ui manager
+ * @action: the action
+ *
+ * The ::pre-activate signal is emitted just before the @action
+ * is activated.
+ *
+ * This is intended for applications to get notification
+ * just before any action is activated.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+ ui_manager_signals[PRE_ACTIVATE] =
+ g_signal_new (I_("pre-activate"),
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
+ G_STRUCT_OFFSET (GtkUIManagerClass, pre_activate),
+ NULL, NULL,
+ _gtk_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ GTK_TYPE_ACTION);
+
+ /**
+ * GtkUIManager::post-activate:
+ * @manager: the ui manager
+ * @action: the action
+ *
+ * The ::post-activate signal is emitted just after the @action
+ * is activated.
+ *
+ * This is intended for applications to get notification
+ * just after any action is activated.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ */
+ ui_manager_signals[POST_ACTIVATE] =
+ g_signal_new (I_("post-activate"),
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
+ G_STRUCT_OFFSET (GtkUIManagerClass, post_activate),
+ NULL, NULL,
+ _gtk_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ GTK_TYPE_ACTION);
+
+ klass->add_widget = NULL;
+ klass->actions_changed = NULL;
+ klass->connect_proxy = NULL;
+ klass->disconnect_proxy = NULL;
+ klass->pre_activate = NULL;
+ klass->post_activate = NULL;
+}
+
+static void
+gtk_ui_manager_init (GtkUIManager *manager)
+{
+ guint merge_id;
+ GNode *node;
+
+ manager->private_data = gtk_ui_manager_get_instance_private (manager);
+
+ manager->private_data->accel_group = gtk_accel_group_new ();
+
+ manager->private_data->root_node = NULL;
+ manager->private_data->action_groups = NULL;
+
+ manager->private_data->last_merge_id = 0;
+ manager->private_data->add_tearoffs = FALSE;
+
+ merge_id = gtk_ui_manager_new_merge_id (manager);
+ node = get_child_node (manager, NULL, NULL, "ui", 2,
+ NODE_TYPE_ROOT, TRUE, FALSE);
+ node_prepend_ui_reference (node, merge_id, 0);
+}
+
+static void
+gtk_ui_manager_finalize (GObject *object)
+{
+ GtkUIManager *manager = GTK_UI_MANAGER (object);
+
+ if (manager->private_data->update_tag != 0)
+ {
+ g_source_remove (manager->private_data->update_tag);
+ manager->private_data->update_tag = 0;
+ }
+
+ g_node_traverse (manager->private_data->root_node,
+ G_POST_ORDER, G_TRAVERSE_ALL, -1,
+ (GNodeTraverseFunc)free_node, NULL);
+ g_node_destroy (manager->private_data->root_node);
+ manager->private_data->root_node = NULL;
+
+ g_list_free_full (manager->private_data->action_groups, g_object_unref);
+ manager->private_data->action_groups = NULL;
+
+ g_object_unref (manager->private_data->accel_group);
+ manager->private_data->accel_group = NULL;
+
+ G_OBJECT_CLASS (gtk_ui_manager_parent_class)->finalize (object);
+}
+
+static void
+gtk_ui_manager_buildable_init (GtkBuildableIface *iface)
+{
+ iface->add_child = gtk_ui_manager_buildable_add_child;
+ iface->construct_child = gtk_ui_manager_buildable_construct_child;
+ iface->custom_tag_start = gtk_ui_manager_buildable_custom_tag_start;
+ iface->custom_tag_end = gtk_ui_manager_buildable_custom_tag_end;
+}
+
+static void
+gtk_ui_manager_buildable_add_child (GtkBuildable *buildable,
+ GtkBuilder *builder,
+ GObject *child,
+ const gchar *type)
+{
+ GtkUIManager *manager = GTK_UI_MANAGER (buildable);
+ guint pos;
+
+ g_return_if_fail (GTK_IS_ACTION_GROUP (child));
+
+ pos = g_list_length (manager->private_data->action_groups);
+
+ gtk_ui_manager_insert_action_group (manager,
+ GTK_ACTION_GROUP (child),
+ pos);
+}
+
+static void
+child_hierarchy_changed_cb (GtkWidget *widget,
+ GtkWidget *unused,
+ GtkUIManager *uimgr)
+{
+ GtkWidget *toplevel;
+ GtkAccelGroup *group;
+ GSList *groups;
+
+ toplevel = gtk_widget_get_toplevel (widget);
+ if (!toplevel || !GTK_IS_WINDOW (toplevel))
+ return;
+
+ group = gtk_ui_manager_get_accel_group (uimgr);
+ groups = gtk_accel_groups_from_object (G_OBJECT (toplevel));
+ if (g_slist_find (groups, group) == NULL)
+ gtk_window_add_accel_group (GTK_WINDOW (toplevel), group);
+
+ g_signal_handlers_disconnect_by_func (widget,
+ child_hierarchy_changed_cb,
+ uimgr);
+}
+
+static GObject *
+gtk_ui_manager_buildable_construct_child (GtkBuildable *buildable,
+ GtkBuilder *builder,
+ const gchar *id)
+{
+ GtkWidget *widget;
+ char *name;
+
+ name = g_strdup_printf ("ui/%s", id);
+ widget = gtk_ui_manager_get_widget (GTK_UI_MANAGER (buildable), name);
+ if (!widget)
+ {
+ g_error ("Unknown ui manager child: %s\n", name);
+ g_free (name);
+ return NULL;
+ }
+ g_free (name);
+
+ g_signal_connect (widget, "hierarchy-changed",
+ G_CALLBACK (child_hierarchy_changed_cb),
+ GTK_UI_MANAGER (buildable));
+ return g_object_ref (widget);
+}
+
+static void
+gtk_ui_manager_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GtkUIManager *manager = GTK_UI_MANAGER (object);
+
+ switch (prop_id)
+ {
+ case PROP_ADD_TEAROFFS:
+ gtk_ui_manager_do_set_add_tearoffs (manager, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gtk_ui_manager_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GtkUIManager *manager = GTK_UI_MANAGER (object);
+
+ switch (prop_id)
+ {
+ case PROP_ADD_TEAROFFS:
+ g_value_set_boolean (value, manager->private_data->add_tearoffs);
+ break;
+ case PROP_UI:
+ g_value_take_string (value, gtk_ui_manager_get_ui (manager));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static GtkWidget *
+gtk_ui_manager_real_get_widget (GtkUIManager *manager,
+ const gchar *path)
+{
+ GNode *node;
+
+ /* ensure that there are no pending updates before we get the
+ * widget */
+ gtk_ui_manager_ensure_update (manager);
+
+ node = get_node (manager, path, NODE_TYPE_UNDECIDED, FALSE);
+
+ if (node == NULL)
+ return NULL;
+
+ return NODE_INFO (node)->proxy;
+}
+
+static GtkAction *
+gtk_ui_manager_real_get_action (GtkUIManager *manager,
+ const gchar *path)
+{
+ GNode *node;
+
+ /* ensure that there are no pending updates before we get
+ * the action */
+ gtk_ui_manager_ensure_update (manager);
+
+ node = get_node (manager, path, NODE_TYPE_UNDECIDED, FALSE);
+
+ if (node == NULL)
+ return NULL;
+
+ return NODE_INFO (node)->action;
+}
+
+
+/**
+ * gtk_ui_manager_new:
+ *
+ * Creates a new ui manager object.
+ *
+ * Return value: a new ui manager object.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+GtkUIManager*
+gtk_ui_manager_new (void)
+{
+ return g_object_new (GTK_TYPE_UI_MANAGER, NULL);
+}
+
+
+/**
+ * gtk_ui_manager_get_add_tearoffs:
+ * @manager: a #GtkUIManager
+ *
+ * Returns whether menus generated by this #GtkUIManager
+ * will have tearoff menu items.
+ *
+ * Return value: whether tearoff menu items are added
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.4: Tearoff menus are deprecated and should not
+ * be used in newly written code.
+ **/
+gboolean
+gtk_ui_manager_get_add_tearoffs (GtkUIManager *manager)
+{
+ g_return_val_if_fail (GTK_IS_UI_MANAGER (manager), FALSE);
+
+ return manager->private_data->add_tearoffs;
+}
+
+
+/**
+ * gtk_ui_manager_set_add_tearoffs:
+ * @manager: a #GtkUIManager
+ * @add_tearoffs: whether tearoff menu items are added
+ *
+ * Sets the "add_tearoffs" property, which controls whether menus
+ * generated by this #GtkUIManager will have tearoff menu items.
+ *
+ * Note that this only affects regular menus. Generated popup
+ * menus never have tearoff menu items.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.4: Tearoff menus are deprecated and should not
+ * be used in newly written code.
+ **/
+void
+gtk_ui_manager_set_add_tearoffs (GtkUIManager *manager,
+ gboolean add_tearoffs)
+{
+ g_return_if_fail (GTK_IS_UI_MANAGER (manager));
+
+ gtk_ui_manager_do_set_add_tearoffs (manager, add_tearoffs);
+}
+
+static void
+gtk_ui_manager_do_set_add_tearoffs (GtkUIManager *manager,
+ gboolean add_tearoffs)
+{
+ add_tearoffs = add_tearoffs != FALSE;
+
+ if (add_tearoffs != manager->private_data->add_tearoffs)
+ {
+ manager->private_data->add_tearoffs = add_tearoffs;
+
+ dirty_all_nodes (manager);
+
+ g_object_notify (G_OBJECT (manager), "add-tearoffs");
+ }
+}
+
+static void
+cb_proxy_connect_proxy (GtkActionGroup *group,
+ GtkAction *action,
+ GtkWidget *proxy,
+ GtkUIManager *manager)
+{
+ g_signal_emit (manager, ui_manager_signals[CONNECT_PROXY], 0, action, proxy);
+}
+
+static void
+cb_proxy_disconnect_proxy (GtkActionGroup *group,
+ GtkAction *action,
+ GtkWidget *proxy,
+ GtkUIManager *manager)
+{
+ g_signal_emit (manager, ui_manager_signals[DISCONNECT_PROXY], 0, action, proxy);
+}
+
+static void
+cb_proxy_pre_activate (GtkActionGroup *group,
+ GtkAction *action,
+ GtkUIManager *manager)
+{
+ g_signal_emit (manager, ui_manager_signals[PRE_ACTIVATE], 0, action);
+}
+
+static void
+cb_proxy_post_activate (GtkActionGroup *group,
+ GtkAction *action,
+ GtkUIManager *manager)
+{
+ g_signal_emit (manager, ui_manager_signals[POST_ACTIVATE], 0, action);
+}
+
+/**
+ * gtk_ui_manager_insert_action_group:
+ * @manager: a #GtkUIManager object
+ * @action_group: the action group to be inserted
+ * @pos: the position at which the group will be inserted.
+ *
+ * Inserts an action group into the list of action groups associated
+ * with @manager. Actions in earlier groups hide actions with the same
+ * name in later groups.
+ *
+ * If @pos is larger than the number of action groups in @manager, or
+ * negative, @action_group will be inserted at the end of the internal
+ * list.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+void
+gtk_ui_manager_insert_action_group (GtkUIManager *manager,
+ GtkActionGroup *action_group,
+ gint pos)
+{
+#ifdef G_ENABLE_DEBUG
+ GList *l;
+ const char *group_name;
+#endif
+
+ g_return_if_fail (GTK_IS_UI_MANAGER (manager));
+ g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
+ g_return_if_fail (g_list_find (manager->private_data->action_groups,
+ action_group) == NULL);
+
+#ifdef G_ENABLE_DEBUG
+ group_name = gtk_action_group_get_name (action_group);
+
+ for (l = manager->private_data->action_groups; l; l = l->next)
+ {
+ GtkActionGroup *group = l->data;
+
+ if (strcmp (gtk_action_group_get_name (group), group_name) == 0)
+ {
+ g_warning ("Inserting action group '%s' into UI manager which "
+ "already has a group with this name\n", group_name);
+ break;
+ }
+ }
+#endif /* G_ENABLE_DEBUG */
+
+ g_object_ref (action_group);
+ manager->private_data->action_groups =
+ g_list_insert (manager->private_data->action_groups, action_group, pos);
+ g_object_connect (action_group,
+ "object-signal::connect-proxy", G_CALLBACK (cb_proxy_connect_proxy), manager,
+ "object-signal::disconnect-proxy", G_CALLBACK (cb_proxy_disconnect_proxy), manager,
+ "object-signal::pre-activate", G_CALLBACK (cb_proxy_pre_activate), manager,
+ "object-signal::post-activate", G_CALLBACK (cb_proxy_post_activate), manager,
+ NULL);
+
+ /* dirty all nodes, as action bindings may change */
+ dirty_all_nodes (manager);
+
+ g_signal_emit (manager, ui_manager_signals[ACTIONS_CHANGED], 0);
+}
+
+/**
+ * gtk_ui_manager_remove_action_group:
+ * @manager: a #GtkUIManager object
+ * @action_group: the action group to be removed
+ *
+ * Removes an action group from the list of action groups associated
+ * with @manager.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+void
+gtk_ui_manager_remove_action_group (GtkUIManager *manager,
+ GtkActionGroup *action_group)
+{
+ g_return_if_fail (GTK_IS_UI_MANAGER (manager));
+ g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
+ g_return_if_fail (g_list_find (manager->private_data->action_groups,
+ action_group) != NULL);
+
+ manager->private_data->action_groups =
+ g_list_remove (manager->private_data->action_groups, action_group);
+
+ g_object_disconnect (action_group,
+ "any-signal::connect-proxy", G_CALLBACK (cb_proxy_connect_proxy), manager,
+ "any-signal::disconnect-proxy", G_CALLBACK (cb_proxy_disconnect_proxy), manager,
+ "any-signal::pre-activate", G_CALLBACK (cb_proxy_pre_activate), manager,
+ "any-signal::post-activate", G_CALLBACK (cb_proxy_post_activate), manager,
+ NULL);
+ g_object_unref (action_group);
+
+ /* dirty all nodes, as action bindings may change */
+ dirty_all_nodes (manager);
+
+ g_signal_emit (manager, ui_manager_signals[ACTIONS_CHANGED], 0);
+}
+
+/**
+ * gtk_ui_manager_get_action_groups:
+ * @manager: a #GtkUIManager object
+ *
+ * Returns the list of action groups associated with @manager.
+ *
+ * Return value: (element-type GtkActionGroup) (transfer none): a #GList of
+ * action groups. The list is owned by GTK+
+ * and should not be modified.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+GList *
+gtk_ui_manager_get_action_groups (GtkUIManager *manager)
+{
+ g_return_val_if_fail (GTK_IS_UI_MANAGER (manager), NULL);
+
+ return manager->private_data->action_groups;
+}
+
+/**
+ * gtk_ui_manager_get_accel_group:
+ * @manager: a #GtkUIManager object
+ *
+ * Returns the #GtkAccelGroup associated with @manager.
+ *
+ * Return value: (transfer none): the #GtkAccelGroup.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+GtkAccelGroup *
+gtk_ui_manager_get_accel_group (GtkUIManager *manager)
+{
+ g_return_val_if_fail (GTK_IS_UI_MANAGER (manager), NULL);
+
+ return manager->private_data->accel_group;
+}
+
+/**
+ * gtk_ui_manager_get_widget:
+ * @manager: a #GtkUIManager
+ * @path: a path
+ *
+ * Looks up a widget by following a path.
+ * The path consists of the names specified in the XML description of the UI.
+ * separated by '/'. Elements which don't have a name or action attribute in
+ * the XML (e.g. <popup>) can be addressed by their XML element name
+ * (e.g. "popup"). The root element ("/ui") can be omitted in the path.
+ *
+ * Note that the widget found by following a path that ends in a <menu>
+ * element is the menuitem to which the menu is attached, not the menu itmanager.
+ *
+ * Also note that the widgets constructed by a ui manager are not tied to
+ * the lifecycle of the ui manager. If you add the widgets returned by this
+ * function to some container or explicitly ref them, they will survive the
+ * destruction of the ui manager.
+ *
+ * Return value: (transfer none): the widget found by following the path, or %NULL if no widget
+ * was found.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+GtkWidget *
+gtk_ui_manager_get_widget (GtkUIManager *manager,
+ const gchar *path)
+{
+ g_return_val_if_fail (GTK_IS_UI_MANAGER (manager), NULL);
+ g_return_val_if_fail (path != NULL, NULL);
+
+ return GTK_UI_MANAGER_GET_CLASS (manager)->get_widget (manager, path);
+}
+
+typedef struct {
+ GtkUIManagerItemType types;
+ GSList *list;
+} ToplevelData;
+
+static void
+collect_toplevels (GNode *node,
+ gpointer user_data)
+{
+ ToplevelData *data = user_data;
+
+ if (NODE_INFO (node)->proxy)
+ {
+ switch (NODE_INFO (node)->type)
+ {
+ case NODE_TYPE_MENUBAR:
+ if (data->types & GTK_UI_MANAGER_MENUBAR)
+ data->list = g_slist_prepend (data->list, NODE_INFO (node)->proxy);
+ break;
+ case NODE_TYPE_TOOLBAR:
+ if (data->types & GTK_UI_MANAGER_TOOLBAR)
+ data->list = g_slist_prepend (data->list, NODE_INFO (node)->proxy);
+ break;
+ case NODE_TYPE_POPUP:
+ if (data->types & GTK_UI_MANAGER_POPUP)
+ data->list = g_slist_prepend (data->list, NODE_INFO (node)->proxy);
+ break;
+ default: ;
+ }
+ }
+}
+
+/**
+ * gtk_ui_manager_get_toplevels:
+ * @manager: a #GtkUIManager
+ * @types: specifies the types of toplevel widgets to include. Allowed
+ * types are #GTK_UI_MANAGER_MENUBAR, #GTK_UI_MANAGER_TOOLBAR and
+ * #GTK_UI_MANAGER_POPUP.
+ *
+ * Obtains a list of all toplevel widgets of the requested types.
+ *
+ * Return value: (element-type GtkWidget) (transfer container): a newly-allocated #GSList of
+ * all toplevel widgets of the requested types. Free the returned list with g_slist_free().
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+GSList *
+gtk_ui_manager_get_toplevels (GtkUIManager *manager,
+ GtkUIManagerItemType types)
+{
+ ToplevelData data;
+
+ g_return_val_if_fail (GTK_IS_UI_MANAGER (manager), NULL);
+ g_return_val_if_fail ((~(GTK_UI_MANAGER_MENUBAR |
+ GTK_UI_MANAGER_TOOLBAR |
+ GTK_UI_MANAGER_POPUP) & types) == 0, NULL);
+
+
+ data.types = types;
+ data.list = NULL;
+
+ g_node_children_foreach (manager->private_data->root_node,
+ G_TRAVERSE_ALL,
+ collect_toplevels, &data);
+
+ return data.list;
+}
+
+
+/**
+ * gtk_ui_manager_get_action:
+ * @manager: a #GtkUIManager
+ * @path: a path
+ *
+ * Looks up an action by following a path. See gtk_ui_manager_get_widget()
+ * for more information about paths.
+ *
+ * Return value: (transfer none): the action whose proxy widget is found by following the path,
+ * or %NULL if no widget was found.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+GtkAction *
+gtk_ui_manager_get_action (GtkUIManager *manager,
+ const gchar *path)
+{
+ g_return_val_if_fail (GTK_IS_UI_MANAGER (manager), NULL);
+ g_return_val_if_fail (path != NULL, NULL);
+
+ return GTK_UI_MANAGER_GET_CLASS (manager)->get_action (manager, path);
+}
+
+static gboolean
+node_is_dead (GNode *node)
+{
+ GNode *child;
+
+ if (NODE_INFO (node)->uifiles != NULL)
+ return FALSE;
+
+ for (child = node->children; child != NULL; child = child->next)
+ {
+ if (!node_is_dead (child))
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static GNode *
+get_child_node (GtkUIManager *manager,
+ GNode *parent,
+ GNode *sibling,
+ const gchar *childname,
+ gint childname_length,
+ NodeType node_type,
+ gboolean create,
+ gboolean top)
+{
+ GNode *child = NULL;
+
+ if (parent)
+ {
+ if (childname)
+ {
+ for (child = parent->children; child != NULL; child = child->next)
+ {
+ if (NODE_INFO (child)->name &&
+ strlen (NODE_INFO (child)->name) == childname_length &&
+ !strncmp (NODE_INFO (child)->name, childname, childname_length))
+ {
+ /* if undecided about node type, set it */
+ if (NODE_INFO (child)->type == NODE_TYPE_UNDECIDED)
+ NODE_INFO (child)->type = node_type;
+
+ /* warn about type mismatch */
+ if (NODE_INFO (child)->type != NODE_TYPE_UNDECIDED &&
+ node_type != NODE_TYPE_UNDECIDED &&
+ NODE_INFO (child)->type != node_type)
+ g_warning ("node type doesn't match %d (%s is type %d)",
+ node_type,
+ NODE_INFO (child)->name,
+ NODE_INFO (child)->type);
+
+ if (node_is_dead (child))
+ {
+ /* This node was removed but is still dirty so
+ * it is still in the tree. We want to treat this
+ * as if it didn't exist, which means we move it
+ * to the position it would have been created at.
+ */
+ g_node_unlink (child);
+ goto insert_child;
+ }
+
+ return child;
+ }
+ }
+ }
+ if (!child && create)
+ {
+ Node *mnode;
+
+ mnode = g_slice_new0 (Node);
+ mnode->type = node_type;
+ mnode->name = g_strndup (childname, childname_length);
+
+ child = g_node_new (mnode);
+ insert_child:
+ if (sibling)
+ {
+ if (top)
+ g_node_insert_before (parent, sibling, child);
+ else
+ g_node_insert_after (parent, sibling, child);
+ }
+ else
+ {
+ if (top)
+ g_node_prepend (parent, child);
+ else
+ g_node_append (parent, child);
+ }
+
+ mark_node_dirty (child);
+ }
+ }
+ else
+ {
+ /* handle root node */
+ if (manager->private_data->root_node)
+ {
+ child = manager->private_data->root_node;
+ if (strncmp (NODE_INFO (child)->name, childname, childname_length) != 0)
+ g_warning ("root node name '%s' doesn't match '%s'",
+ childname, NODE_INFO (child)->name);
+ if (NODE_INFO (child)->type != NODE_TYPE_ROOT)
+ g_warning ("base element must be of type ROOT");
+ }
+ else if (create)
+ {
+ Node *mnode;
+
+ mnode = g_slice_new0 (Node);
+ mnode->type = node_type;
+ mnode->name = g_strndup (childname, childname_length);
+ mnode->dirty = TRUE;
+
+ child = manager->private_data->root_node = g_node_new (mnode);
+ }
+ }
+
+ return child;
+}
+
+static GNode *
+get_node (GtkUIManager *manager,
+ const gchar *path,
+ NodeType node_type,
+ gboolean create)
+{
+ const gchar *pos, *end;
+ GNode *parent, *node;
+
+ if (strncmp ("/ui", path, 3) == 0)
+ path += 3;
+
+ end = path + strlen (path);
+ pos = path;
+ parent = node = NULL;
+ while (pos < end)
+ {
+ const gchar *slash;
+ gsize length;
+
+ slash = strchr (pos, '/');
+ if (slash)
+ length = slash - pos;
+ else
+ length = strlen (pos);
+
+ node = get_child_node (manager, parent, NULL, pos, length, NODE_TYPE_UNDECIDED,
+ create, FALSE);
+ if (!node)
+ return NULL;
+
+ pos += length + 1; /* move past the node name and the slash too */
+ parent = node;
+ }
+
+ if (node != NULL && NODE_INFO (node)->type == NODE_TYPE_UNDECIDED)
+ NODE_INFO (node)->type = node_type;
+
+ return node;
+}
+
+static void
+node_ui_reference_free (gpointer data)
+{
+ g_slice_free (NodeUIReference, data);
+}
+
+static gboolean
+free_node (GNode *node)
+{
+ Node *info = NODE_INFO (node);
+
+ g_list_free_full (info->uifiles, node_ui_reference_free);
+ info->uifiles = NULL;
+
+ g_clear_object (&info->action);
+ g_clear_object (&info->proxy);
+ g_clear_object (&info->extra);
+ g_clear_pointer (&info->name, g_free);
+ g_slice_free (Node, info);
+ node->data = NULL;
+
+ return FALSE;
+}
+
+/**
+ * gtk_ui_manager_new_merge_id:
+ * @manager: a #GtkUIManager
+ *
+ * Returns an unused merge id, suitable for use with
+ * gtk_ui_manager_add_ui().
+ *
+ * Return value: an unused merge id.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+guint
+gtk_ui_manager_new_merge_id (GtkUIManager *manager)
+{
+ manager->private_data->last_merge_id++;
+
+ return manager->private_data->last_merge_id;
+}
+
+static void
+node_prepend_ui_reference (GNode *gnode,
+ guint merge_id,
+ GQuark action_quark)
+{
+ Node *node = NODE_INFO (gnode);
+ NodeUIReference *reference = NULL;
+
+ if (node->uifiles &&
+ ((NodeUIReference *)node->uifiles->data)->merge_id == merge_id)
+ reference = node->uifiles->data;
+ else
+ {
+ reference = g_slice_new (NodeUIReference);
+ node->uifiles = g_list_prepend (node->uifiles, reference);
+ }
+
+ reference->merge_id = merge_id;
+ reference->action_quark = action_quark;
+
+ mark_node_dirty (gnode);
+}
+
+static void
+node_remove_ui_reference (GNode *gnode,
+ guint merge_id)
+{
+ Node *node = NODE_INFO (gnode);
+ GList *p;
+
+ for (p = node->uifiles; p != NULL; p = p->next)
+ {
+ NodeUIReference *reference = p->data;
+
+ if (reference->merge_id == merge_id)
+ {
+ if (p == node->uifiles)
+ mark_node_dirty (gnode);
+ node->uifiles = g_list_delete_link (node->uifiles, p);
+ g_slice_free (NodeUIReference, reference);
+
+ break;
+ }
+ }
+}
+
+/* -------------------- The UI file parser -------------------- */
+
+typedef enum
+{
+ STATE_START,
+ STATE_ROOT,
+ STATE_MENU,
+ STATE_TOOLBAR,
+ STATE_MENUITEM,
+ STATE_TOOLITEM,
+ STATE_ACCELERATOR,
+ STATE_END
+} ParseState;
+
+typedef struct _ParseContext ParseContext;
+struct _ParseContext
+{
+ ParseState state;
+ ParseState prev_state;
+
+ GtkUIManager *manager;
+
+ GNode *current;
+
+ guint merge_id;
+};
+
+static void
+start_element_handler (GMarkupParseContext *context,
+ const gchar *element_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ gpointer user_data,
+ GError **error)
+{
+ ParseContext *ctx = user_data;
+ GtkUIManager *manager = ctx->manager;
+
+ gint i;
+ const gchar *node_name;
+ const gchar *action;
+ GQuark action_quark;
+ gboolean top;
+ gboolean expand = FALSE;
+ gboolean accelerators = FALSE;
+ gboolean always_show_image_set = FALSE, always_show_image = FALSE;
+
+ gboolean raise_error = TRUE;
+
+ node_name = NULL;
+ action = NULL;
+ action_quark = 0;
+ top = FALSE;
+
+ for (i = 0; attribute_names[i] != NULL; i++)
+ {
+ if (!strcmp (attribute_names[i], "name"))
+ {
+ node_name = attribute_values[i];
+ }
+ else if (!strcmp (attribute_names[i], "action"))
+ {
+ action = attribute_values[i];
+ action_quark = g_quark_from_string (attribute_values[i]);
+ }
+ else if (!strcmp (attribute_names[i], "position"))
+ {
+ top = !strcmp (attribute_values[i], "top");
+ }
+ else if (!strcmp (attribute_names[i], "expand"))
+ {
+ expand = !strcmp (attribute_values[i], "true");
+ }
+ else if (!strcmp (attribute_names[i], "accelerators"))
+ {
+ accelerators = !strcmp (attribute_values[i], "true");
+ }
+ else if (!strcmp (attribute_names[i], "always-show-image"))
+ {
+ always_show_image_set = TRUE;
+ always_show_image = !strcmp (attribute_values[i], "true");
+ }
+ /* else silently skip unknown attributes to be compatible with
+ * future additional attributes.
+ */
+ }
+
+ /* Work out a name for this node. Either the name attribute, or
+ * the action, or the element name */
+ if (node_name == NULL)
+ {
+ if (action != NULL)
+ node_name = action;
+ else
+ node_name = element_name;
+ }
+
+ switch (element_name[0])
+ {
+ case 'a':
+ if (ctx->state == STATE_ROOT && !strcmp (element_name, "accelerator"))
+ {
+ ctx->state = STATE_ACCELERATOR;
+ ctx->current = get_child_node (manager, ctx->current, NULL,
+ node_name, strlen (node_name),
+ NODE_TYPE_ACCELERATOR,
+ TRUE, FALSE);
+ if (NODE_INFO (ctx->current)->action_name == 0)
+ NODE_INFO (ctx->current)->action_name = action_quark;
+
+ node_prepend_ui_reference (ctx->current, ctx->merge_id, action_quark);
+
+ raise_error = FALSE;
+ }
+ break;
+ case 'u':
+ if (ctx->state == STATE_START && !strcmp (element_name, "ui"))
+ {
+ ctx->state = STATE_ROOT;
+ ctx->current = manager->private_data->root_node;
+ raise_error = FALSE;
+
+ node_prepend_ui_reference (ctx->current, ctx->merge_id, action_quark);
+ }
+ break;
+ case 'm':
+ if (ctx->state == STATE_ROOT && !strcmp (element_name, "menubar"))
+ {
+ ctx->state = STATE_MENU;
+ ctx->current = get_child_node (manager, ctx->current, NULL,
+ node_name, strlen (node_name),
+ NODE_TYPE_MENUBAR,
+ TRUE, FALSE);
+ if (NODE_INFO (ctx->current)->action_name == 0)
+ NODE_INFO (ctx->current)->action_name = action_quark;
+
+ node_prepend_ui_reference (ctx->current, ctx->merge_id, action_quark);
+ mark_node_dirty (ctx->current);
+
+ raise_error = FALSE;
+ }
+ else if (ctx->state == STATE_MENU && !strcmp (element_name, "menu"))
+ {
+ ctx->current = get_child_node (manager, ctx->current, NULL,
+ node_name, strlen (node_name),
+ NODE_TYPE_MENU,
+ TRUE, top);
+ if (NODE_INFO (ctx->current)->action_name == 0)
+ NODE_INFO (ctx->current)->action_name = action_quark;
+
+ node_prepend_ui_reference (ctx->current, ctx->merge_id, action_quark);
+
+ raise_error = FALSE;
+ }
+ else if (ctx->state == STATE_TOOLITEM && !strcmp (element_name, "menu"))
+ {
+ ctx->state = STATE_MENU;
+
+ ctx->current = get_child_node (manager, g_node_last_child (ctx->current), NULL,
+ node_name, strlen (node_name),
+ NODE_TYPE_MENU,
+ TRUE, top);
+ if (NODE_INFO (ctx->current)->action_name == 0)
+ NODE_INFO (ctx->current)->action_name = action_quark;
+
+ node_prepend_ui_reference (ctx->current, ctx->merge_id, action_quark);
+
+ raise_error = FALSE;
+ }
+ else if (ctx->state == STATE_MENU && !strcmp (element_name, "menuitem"))
+ {
+ GNode *node;
+
+ ctx->state = STATE_MENUITEM;
+ node = get_child_node (manager, ctx->current, NULL,
+ node_name, strlen (node_name),
+ NODE_TYPE_MENUITEM,
+ TRUE, top);
+ if (NODE_INFO (node)->action_name == 0)
+ NODE_INFO (node)->action_name = action_quark;
+
+ NODE_INFO (node)->always_show_image_set = always_show_image_set;
+ NODE_INFO (node)->always_show_image = always_show_image;
+
+ node_prepend_ui_reference (node, ctx->merge_id, action_quark);
+
+ raise_error = FALSE;
+ }
+ break;
+ case 'p':
+ if (ctx->state == STATE_ROOT && !strcmp (element_name, "popup"))
+ {
+ ctx->state = STATE_MENU;
+ ctx->current = get_child_node (manager, ctx->current, NULL,
+ node_name, strlen (node_name),
+ NODE_TYPE_POPUP,
+ TRUE, FALSE);
+
+ NODE_INFO (ctx->current)->popup_accels = accelerators;
+
+ if (NODE_INFO (ctx->current)->action_name == 0)
+ NODE_INFO (ctx->current)->action_name = action_quark;
+
+ node_prepend_ui_reference (ctx->current, ctx->merge_id, action_quark);
+
+ raise_error = FALSE;
+ }
+ else if ((ctx->state == STATE_MENU || ctx->state == STATE_TOOLBAR) &&
+ !strcmp (element_name, "placeholder"))
+ {
+ if (ctx->state == STATE_TOOLBAR)
+ ctx->current = get_child_node (manager, ctx->current, NULL,
+ node_name, strlen (node_name),
+ NODE_TYPE_TOOLBAR_PLACEHOLDER,
+ TRUE, top);
+ else
+ ctx->current = get_child_node (manager, ctx->current, NULL,
+ node_name, strlen (node_name),
+ NODE_TYPE_MENU_PLACEHOLDER,
+ TRUE, top);
+
+ node_prepend_ui_reference (ctx->current, ctx->merge_id, action_quark);
+
+ raise_error = FALSE;
+ }
+ break;
+ case 's':
+ if ((ctx->state == STATE_MENU || ctx->state == STATE_TOOLBAR) &&
+ !strcmp (element_name, "separator"))
+ {
+ GNode *node;
+ gint length;
+
+ if (ctx->state == STATE_TOOLBAR)
+ ctx->state = STATE_TOOLITEM;
+ else
+ ctx->state = STATE_MENUITEM;
+ if (!strcmp (node_name, "separator"))
+ {
+ node_name = NULL;
+ length = 0;
+ }
+ else
+ length = strlen (node_name);
+ node = get_child_node (manager, ctx->current, NULL,
+ node_name, length,
+ NODE_TYPE_SEPARATOR,
+ TRUE, top);
+
+ NODE_INFO (node)->expand = expand;
+
+ if (NODE_INFO (node)->action_name == 0)
+ NODE_INFO (node)->action_name = action_quark;
+
+ node_prepend_ui_reference (node, ctx->merge_id, action_quark);
+
+ raise_error = FALSE;
+ }
+ break;
+ case 't':
+ if (ctx->state == STATE_ROOT && !strcmp (element_name, "toolbar"))
+ {
+ ctx->state = STATE_TOOLBAR;
+ ctx->current = get_child_node (manager, ctx->current, NULL,
+ node_name, strlen (node_name),
+ NODE_TYPE_TOOLBAR,
+ TRUE, FALSE);
+ if (NODE_INFO (ctx->current)->action_name == 0)
+ NODE_INFO (ctx->current)->action_name = action_quark;
+
+ node_prepend_ui_reference (ctx->current, ctx->merge_id, action_quark);
+
+ raise_error = FALSE;
+ }
+ else if (ctx->state == STATE_TOOLBAR && !strcmp (element_name, "toolitem"))
+ {
+ GNode *node;
+
+ ctx->state = STATE_TOOLITEM;
+ node = get_child_node (manager, ctx->current, NULL,
+ node_name, strlen (node_name),
+ NODE_TYPE_TOOLITEM,
+ TRUE, top);
+ if (NODE_INFO (node)->action_name == 0)
+ NODE_INFO (node)->action_name = action_quark;
+
+ node_prepend_ui_reference (node, ctx->merge_id, action_quark);
+
+ raise_error = FALSE;
+ }
+ break;
+ default:
+ break;
+ }
+ if (raise_error)
+ {
+ gint line_number, char_number;
+
+ g_markup_parse_context_get_position (context,
+ &line_number, &char_number);
+ g_set_error (error,
+ G_MARKUP_ERROR,
+ G_MARKUP_ERROR_UNKNOWN_ELEMENT,
+ _("Unexpected start tag '%s' on line %d char %d"),
+ element_name,
+ line_number, char_number);
+ }
+}
+
+static void
+end_element_handler (GMarkupParseContext *context,
+ const gchar *element_name,
+ gpointer user_data,
+ GError **error)
+{
+ ParseContext *ctx = user_data;
+
+ switch (ctx->state)
+ {
+ case STATE_START:
+ case STATE_END:
+ /* no need to GError here, GMarkup already catches this */
+ break;
+ case STATE_ROOT:
+ ctx->current = NULL;
+ ctx->state = STATE_END;
+ break;
+ case STATE_MENU:
+ case STATE_TOOLBAR:
+ case STATE_ACCELERATOR:
+ ctx->current = ctx->current->parent;
+ if (NODE_INFO (ctx->current)->type == NODE_TYPE_ROOT)
+ ctx->state = STATE_ROOT;
+ else if (NODE_INFO (ctx->current)->type == NODE_TYPE_TOOLITEM)
+ {
+ ctx->current = ctx->current->parent;
+ ctx->state = STATE_TOOLITEM;
+ }
+ /* else, stay in same state */
+ break;
+ case STATE_MENUITEM:
+ ctx->state = STATE_MENU;
+ break;
+ case STATE_TOOLITEM:
+ ctx->state = STATE_TOOLBAR;
+ break;
+ }
+}
+
+static void
+cleanup (GMarkupParseContext *context,
+ GError *error,
+ gpointer user_data)
+{
+ ParseContext *ctx = user_data;
+
+ ctx->current = NULL;
+ /* should also walk through the tree and get rid of nodes related to
+ * this UI file's tag */
+
+ gtk_ui_manager_remove_ui (ctx->manager, ctx->merge_id);
+}
+
+static gboolean
+xml_isspace (char c)
+{
+ return c == ' ' || c == '\t' || c == '\n' || c == '\r';
+}
+
+static void
+text_handler (GMarkupParseContext *context,
+ const gchar *text,
+ gsize text_len,
+ gpointer user_data,
+ GError **error)
+{
+ const gchar *p;
+ const gchar *end;
+
+ p = text;
+ end = text + text_len;
+ while (p != end && xml_isspace (*p))
+ ++p;
+
+ if (p != end)
+ {
+ gint line_number, char_number;
+
+ g_markup_parse_context_get_position (context,
+ &line_number, &char_number);
+ g_set_error (error,
+ G_MARKUP_ERROR,
+ G_MARKUP_ERROR_INVALID_CONTENT,
+ _("Unexpected character data on line %d char %d"),
+ line_number, char_number);
+ }
+}
+
+
+static const GMarkupParser ui_parser = {
+ start_element_handler,
+ end_element_handler,
+ text_handler,
+ NULL,
+ cleanup
+};
+
+static guint
+add_ui_from_string (GtkUIManager *manager,
+ const gchar *buffer,
+ gssize length,
+ gboolean needs_root,
+ GError **error)
+{
+ ParseContext ctx = { 0 };
+ GMarkupParseContext *context;
+
+ ctx.state = STATE_START;
+ ctx.manager = manager;
+ ctx.current = NULL;
+ ctx.merge_id = gtk_ui_manager_new_merge_id (manager);
+
+ context = g_markup_parse_context_new (&ui_parser, 0, &ctx, NULL);
+
+ if (needs_root)
+ if (!g_markup_parse_context_parse (context, "<ui>", -1, error))
+ goto out;
+
+ if (!g_markup_parse_context_parse (context, buffer, length, error))
+ goto out;
+
+ if (needs_root)
+ if (!g_markup_parse_context_parse (context, "</ui>", -1, error))
+ goto out;
+
+ if (!g_markup_parse_context_end_parse (context, error))
+ goto out;
+
+ g_markup_parse_context_free (context);
+
+ queue_update (manager);
+
+ g_object_notify (G_OBJECT (manager), "ui");
+
+ return ctx.merge_id;
+
+ out:
+
+ g_markup_parse_context_free (context);
+
+ return 0;
+}
+
+/**
+ * gtk_ui_manager_add_ui_from_string:
+ * @manager: a #GtkUIManager object
+ * @buffer: the string to parse
+ * @length: the length of @buffer (may be -1 if @buffer is nul-terminated)
+ * @error: return location for an error
+ *
+ * Parses a string containing a <link linkend="XML-UI">UI definition</link> and
+ * merges it with the current contents of @manager. An enclosing <ui>
+ * element is added if it is missing.
+ *
+ * Return value: The merge id for the merged UI. The merge id can be used
+ * to unmerge the UI with gtk_ui_manager_remove_ui(). If an error occurred,
+ * the return value is 0.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+guint
+gtk_ui_manager_add_ui_from_string (GtkUIManager *manager,
+ const gchar *buffer,
+ gssize length,
+ GError **error)
+{
+ gboolean needs_root = TRUE;
+ const gchar *p;
+ const gchar *end;
+
+ g_return_val_if_fail (GTK_IS_UI_MANAGER (manager), 0);
+ g_return_val_if_fail (buffer != NULL, 0);
+
+ if (length < 0)
+ length = strlen (buffer);
+
+ p = buffer;
+ end = buffer + length;
+ while (p != end && xml_isspace (*p))
+ ++p;
+
+ if (end - p >= 4 && strncmp (p, "<ui>", 4) == 0)
+ needs_root = FALSE;
+
+ return add_ui_from_string (manager, buffer, length, needs_root, error);
+}
+
+/**
+ * gtk_ui_manager_add_ui_from_file:
+ * @manager: a #GtkUIManager object
+ * @filename: (type filename): the name of the file to parse
+ * @error: return location for an error
+ *
+ * Parses a file containing a <link linkend="XML-UI">UI definition</link> and
+ * merges it with the current contents of @manager.
+ *
+ * Return value: The merge id for the merged UI. The merge id can be used
+ * to unmerge the UI with gtk_ui_manager_remove_ui(). If an error occurred,
+ * the return value is 0.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+guint
+gtk_ui_manager_add_ui_from_file (GtkUIManager *manager,
+ const gchar *filename,
+ GError **error)
+{
+ gchar *buffer;
+ gsize length;
+ guint res;
+
+ g_return_val_if_fail (GTK_IS_UI_MANAGER (manager), 0);
+
+ if (!g_file_get_contents (filename, &buffer, &length, error))
+ return 0;
+
+ res = add_ui_from_string (manager, buffer, length, FALSE, error);
+ g_free (buffer);
+
+ return res;
+}
+
+/**
+ * gtk_ui_manager_add_ui_from_resource:
+ * @manager: a #GtkUIManager object
+ * @resource_path: the resource path of the file to parse
+ * @error: return location for an error
+ *
+ * Parses a resource file containing a <link linkend="XML-UI">UI definition</link> and
+ * merges it with the current contents of @manager.
+ *
+ * Return value: The merge id for the merged UI. The merge id can be used
+ * to unmerge the UI with gtk_ui_manager_remove_ui(). If an error occurred,
+ * the return value is 0.
+ *
+ * Since: 3.4
+ *
+ * Deprecated: 3.10
+ **/
+guint
+gtk_ui_manager_add_ui_from_resource (GtkUIManager *manager,
+ const gchar *resource_path,
+ GError **error)
+{
+ GBytes *data;
+ guint res;
+
+ g_return_val_if_fail (GTK_IS_UI_MANAGER (manager), 0);
+
+ data = g_resources_lookup_data (resource_path, 0, error);
+ if (data == NULL)
+ return 0;
+
+ res = add_ui_from_string (manager, g_bytes_get_data (data, NULL), g_bytes_get_size (data), FALSE, error);
+ g_bytes_unref (data);
+
+ return res;
+}
+
+/**
+ * gtk_ui_manager_add_ui:
+ * @manager: a #GtkUIManager
+ * @merge_id: the merge id for the merged UI, see gtk_ui_manager_new_merge_id()
+ * @path: a path
+ * @name: the name for the added UI element
+ * @action: (allow-none): the name of the action to be proxied, or %NULL to add a separator
+ * @type: the type of UI element to add.
+ * @top: if %TRUE, the UI element is added before its siblings, otherwise it
+ * is added after its siblings.
+ *
+ * Adds a UI element to the current contents of @manager.
+ *
+ * If @type is %GTK_UI_MANAGER_AUTO, GTK+ inserts a menuitem, toolitem or
+ * separator if such an element can be inserted at the place determined by
+ * @path. Otherwise @type must indicate an element that can be inserted at
+ * the place determined by @path.
+ *
+ * If @path points to a menuitem or toolitem, the new element will be inserted
+ * before or after this item, depending on @top.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+void
+gtk_ui_manager_add_ui (GtkUIManager *manager,
+ guint merge_id,
+ const gchar *path,
+ const gchar *name,
+ const gchar *action,
+ GtkUIManagerItemType type,
+ gboolean top)
+{
+ GNode *node;
+ GNode *sibling;
+ GNode *child;
+ NodeType node_type;
+ GQuark action_quark = 0;
+
+ g_return_if_fail (GTK_IS_UI_MANAGER (manager));
+ g_return_if_fail (merge_id > 0);
+ g_return_if_fail (name != NULL || type == GTK_UI_MANAGER_SEPARATOR);
+
+ node = get_node (manager, path, NODE_TYPE_UNDECIDED, FALSE);
+ sibling = NULL;
+
+ if (node == NULL)
+ return;
+
+ node_type = NODE_TYPE_UNDECIDED;
+
+ reswitch:
+ switch (NODE_INFO (node)->type)
+ {
+ case NODE_TYPE_SEPARATOR:
+ case NODE_TYPE_MENUITEM:
+ case NODE_TYPE_TOOLITEM:
+ sibling = node;
+ node = node->parent;
+ goto reswitch;
+ case NODE_TYPE_MENUBAR:
+ case NODE_TYPE_MENU:
+ case NODE_TYPE_POPUP:
+ case NODE_TYPE_MENU_PLACEHOLDER:
+ switch (type)
+ {
+ case GTK_UI_MANAGER_AUTO:
+ if (action != NULL)
+ node_type = NODE_TYPE_MENUITEM;
+ else
+ node_type = NODE_TYPE_SEPARATOR;
+ break;
+ case GTK_UI_MANAGER_MENU:
+ node_type = NODE_TYPE_MENU;
+ break;
+ case GTK_UI_MANAGER_MENUITEM:
+ node_type = NODE_TYPE_MENUITEM;
+ break;
+ case GTK_UI_MANAGER_SEPARATOR:
+ node_type = NODE_TYPE_SEPARATOR;
+ break;
+ case GTK_UI_MANAGER_PLACEHOLDER:
+ node_type = NODE_TYPE_MENU_PLACEHOLDER;
+ break;
+ default: ;
+ /* do nothing */
+ }
+ break;
+ case NODE_TYPE_TOOLBAR:
+ case NODE_TYPE_TOOLBAR_PLACEHOLDER:
+ switch (type)
+ {
+ case GTK_UI_MANAGER_AUTO:
+ if (action != NULL)
+ node_type = NODE_TYPE_TOOLITEM;
+ else
+ node_type = NODE_TYPE_SEPARATOR;
+ break;
+ case GTK_UI_MANAGER_TOOLITEM:
+ node_type = NODE_TYPE_TOOLITEM;
+ break;
+ case GTK_UI_MANAGER_SEPARATOR:
+ node_type = NODE_TYPE_SEPARATOR;
+ break;
+ case GTK_UI_MANAGER_PLACEHOLDER:
+ node_type = NODE_TYPE_TOOLBAR_PLACEHOLDER;
+ break;
+ default: ;
+ /* do nothing */
+ }
+ break;
+ case NODE_TYPE_ROOT:
+ switch (type)
+ {
+ case GTK_UI_MANAGER_MENUBAR:
+ node_type = NODE_TYPE_MENUBAR;
+ break;
+ case GTK_UI_MANAGER_TOOLBAR:
+ node_type = NODE_TYPE_TOOLBAR;
+ break;
+ case GTK_UI_MANAGER_POPUP:
+ case GTK_UI_MANAGER_POPUP_WITH_ACCELS:
+ node_type = NODE_TYPE_POPUP;
+ break;
+ case GTK_UI_MANAGER_ACCELERATOR:
+ node_type = NODE_TYPE_ACCELERATOR;
+ break;
+ default: ;
+ /* do nothing */
+ }
+ break;
+ default: ;
+ /* do nothing */
+ }
+
+ if (node_type == NODE_TYPE_UNDECIDED)
+ {
+ g_warning ("item type %d not suitable for adding at '%s'",
+ type, path);
+ return;
+ }
+
+ child = get_child_node (manager, node, sibling,
+ name, name ? strlen (name) : 0,
+ node_type, TRUE, top);
+
+ if (type == GTK_UI_MANAGER_POPUP_WITH_ACCELS)
+ NODE_INFO (child)->popup_accels = TRUE;
+
+ if (action != NULL)
+ action_quark = g_quark_from_string (action);
+
+ node_prepend_ui_reference (child, merge_id, action_quark);
+
+ if (NODE_INFO (child)->action_name == 0)
+ NODE_INFO (child)->action_name = action_quark;
+
+ queue_update (manager);
+
+ g_object_notify (G_OBJECT (manager), "ui");
+}
+
+static gboolean
+remove_ui (GNode *node,
+ gpointer user_data)
+{
+ guint merge_id = GPOINTER_TO_UINT (user_data);
+
+ node_remove_ui_reference (node, merge_id);
+
+ return FALSE; /* continue */
+}
+
+/**
+ * gtk_ui_manager_remove_ui:
+ * @manager: a #GtkUIManager object
+ * @merge_id: a merge id as returned by gtk_ui_manager_add_ui_from_string()
+ *
+ * Unmerges the part of @manager<!-- -->s content identified by @merge_id.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+void
+gtk_ui_manager_remove_ui (GtkUIManager *manager,
+ guint merge_id)
+{
+ g_return_if_fail (GTK_IS_UI_MANAGER (manager));
+
+ g_node_traverse (manager->private_data->root_node,
+ G_POST_ORDER, G_TRAVERSE_ALL, -1,
+ remove_ui, GUINT_TO_POINTER (merge_id));
+
+ queue_update (manager);
+
+ g_object_notify (G_OBJECT (manager), "ui");
+}
+
+/* -------------------- Updates -------------------- */
+
+
+static GtkAction *
+get_action_by_name (GtkUIManager *merge,
+ const gchar *action_name)
+{
+ GList *tmp;
+
+ if (!action_name)
+ return NULL;
+
+ /* lookup name */
+ for (tmp = merge->private_data->action_groups; tmp != NULL; tmp = tmp->next)
+ {
+ GtkActionGroup *action_group = tmp->data;
+ GtkAction *action;
+
+ action = gtk_action_group_get_action (action_group, action_name);
+
+ if (action)
+ return action;
+ }
+
+ return NULL;
+}
+
+static gboolean
+find_menu_position (GNode *node,
+ GtkWidget **menushell_p,
+ gint *pos_p)
+{
+ GtkWidget *menushell;
+ gint pos = 0;
+
+ g_return_val_if_fail (node != NULL, FALSE);
+ g_return_val_if_fail (NODE_INFO (node)->type == NODE_TYPE_MENU ||
+ NODE_INFO (node)->type == NODE_TYPE_POPUP ||
+ NODE_INFO (node)->type == NODE_TYPE_MENU_PLACEHOLDER ||
+ NODE_INFO (node)->type == NODE_TYPE_MENUITEM ||
+ NODE_INFO (node)->type == NODE_TYPE_SEPARATOR,
+ FALSE);
+
+ /* first sibling -- look at parent */
+ if (node->prev == NULL)
+ {
+ GNode *parent;
+ GList *siblings;
+
+ parent = node->parent;
+ switch (NODE_INFO (parent)->type)
+ {
+ case NODE_TYPE_MENUBAR:
+ case NODE_TYPE_POPUP:
+ menushell = NODE_INFO (parent)->proxy;
+ pos = 0;
+ break;
+ case NODE_TYPE_MENU:
+ menushell = NODE_INFO (parent)->proxy;
+ if (GTK_IS_MENU_ITEM (menushell))
+ menushell = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menushell));
+ siblings = gtk_container_get_children (GTK_CONTAINER (menushell));
+
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
+ if (siblings != NULL && GTK_IS_TEAROFF_MENU_ITEM (siblings->data))
+ pos = 1;
+ else
+ pos = 0;
+
+G_GNUC_END_IGNORE_DEPRECATIONS
+
+ g_list_free (siblings);
+ break;
+ case NODE_TYPE_MENU_PLACEHOLDER:
+ menushell = gtk_widget_get_parent (NODE_INFO (parent)->proxy);
+ g_return_val_if_fail (GTK_IS_MENU_SHELL (menushell), FALSE);
+ pos = g_list_index (GTK_MENU_SHELL (menushell)->priv->children,
+ NODE_INFO (parent)->proxy) + 1;
+ break;
+ default:
+ g_warning ("%s: bad parent node type %d", G_STRLOC,
+ NODE_INFO (parent)->type);
+ return FALSE;
+ }
+ }
+ else
+ {
+ GtkWidget *prev_child;
+ GNode *sibling;
+
+ sibling = node->prev;
+ if (NODE_INFO (sibling)->type == NODE_TYPE_MENU_PLACEHOLDER)
+ prev_child = NODE_INFO (sibling)->extra; /* second Separator */
+ else
+ prev_child = NODE_INFO (sibling)->proxy;
+
+ if (!GTK_IS_WIDGET (prev_child))
+ return FALSE;
+
+ menushell = gtk_widget_get_parent (prev_child);
+ if (!GTK_IS_MENU_SHELL (menushell))
+ return FALSE;
+
+ pos = g_list_index (GTK_MENU_SHELL (menushell)->priv->children, prev_child) + 1;
+ }
+
+ if (menushell_p)
+ *menushell_p = menushell;
+ if (pos_p)
+ *pos_p = pos;
+
+ return TRUE;
+}
+
+static gboolean
+find_toolbar_position (GNode *node,
+ GtkWidget **toolbar_p,
+ gint *pos_p)
+{
+ GtkWidget *toolbar;
+ gint pos;
+
+ g_return_val_if_fail (node != NULL, FALSE);
+ g_return_val_if_fail (NODE_INFO (node)->type == NODE_TYPE_TOOLBAR ||
+ NODE_INFO (node)->type == NODE_TYPE_TOOLBAR_PLACEHOLDER ||
+ NODE_INFO (node)->type == NODE_TYPE_TOOLITEM ||
+ NODE_INFO (node)->type == NODE_TYPE_SEPARATOR,
+ FALSE);
+
+ /* first sibling -- look at parent */
+ if (node->prev == NULL)
+ {
+ GNode *parent;
+
+ parent = node->parent;
+ switch (NODE_INFO (parent)->type)
+ {
+ case NODE_TYPE_TOOLBAR:
+ toolbar = NODE_INFO (parent)->proxy;
+ pos = 0;
+ break;
+ case NODE_TYPE_TOOLBAR_PLACEHOLDER:
+ toolbar = gtk_widget_get_parent (NODE_INFO (parent)->proxy);
+ g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), FALSE);
+ pos = gtk_toolbar_get_item_index (GTK_TOOLBAR (toolbar),
+ GTK_TOOL_ITEM (NODE_INFO (parent)->proxy)) + 1;
+ break;
+ default:
+ g_warning ("%s: bad parent node type %d", G_STRLOC,
+ NODE_INFO (parent)->type);
+ return FALSE;
+ }
+ }
+ else
+ {
+ GtkWidget *prev_child;
+ GNode *sibling;
+
+ sibling = node->prev;
+ if (NODE_INFO (sibling)->type == NODE_TYPE_TOOLBAR_PLACEHOLDER)
+ prev_child = NODE_INFO (sibling)->extra; /* second Separator */
+ else
+ prev_child = NODE_INFO (sibling)->proxy;
+
+ if (!GTK_IS_WIDGET (prev_child))
+ return FALSE;
+
+ toolbar = gtk_widget_get_parent (prev_child);
+ if (!GTK_IS_TOOLBAR (toolbar))
+ return FALSE;
+
+ pos = gtk_toolbar_get_item_index (GTK_TOOLBAR (toolbar),
+ GTK_TOOL_ITEM (prev_child)) + 1;
+ }
+
+ if (toolbar_p)
+ *toolbar_p = toolbar;
+ if (pos_p)
+ *pos_p = pos;
+
+ return TRUE;
+}
+
+enum {
+ SEPARATOR_MODE_SMART,
+ SEPARATOR_MODE_VISIBLE,
+ SEPARATOR_MODE_HIDDEN
+};
+
+static void
+update_smart_separators (GtkWidget *proxy)
+{
+ GtkWidget *parent = NULL;
+
+ if (GTK_IS_MENU (proxy) || GTK_IS_TOOLBAR (proxy))
+ parent = proxy;
+ else if (GTK_IS_MENU_ITEM (proxy) || GTK_IS_TOOL_ITEM (proxy))
+ parent = gtk_widget_get_parent (proxy);
+
+ if (parent)
+ {
+ gboolean visible;
+ gboolean empty;
+ GList *children, *cur, *last;
+ GtkWidget *filler;
+
+ children = gtk_container_get_children (GTK_CONTAINER (parent));
+
+ visible = FALSE;
+ last = NULL;
+ empty = TRUE;
+ filler = NULL;
+
+ cur = children;
+ while (cur)
+ {
+ if (g_object_get_data (cur->data, "gtk-empty-menu-item"))
+ {
+ filler = cur->data;
+ }
+ else if (GTK_IS_SEPARATOR_MENU_ITEM (cur->data) ||
+ GTK_IS_SEPARATOR_TOOL_ITEM (cur->data))
+ {
+ gint mode =
+ GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cur->data),
+ "gtk-separator-mode"));
+ switch (mode)
+ {
+ case SEPARATOR_MODE_VISIBLE:
+ gtk_widget_show (GTK_WIDGET (cur->data));
+ last = NULL;
+ visible = FALSE;
+ break;
+ case SEPARATOR_MODE_HIDDEN:
+ gtk_widget_hide (GTK_WIDGET (cur->data));
+ break;
+ case SEPARATOR_MODE_SMART:
+ if (visible)
+ {
+ gtk_widget_show (GTK_WIDGET (cur->data));
+ last = cur;
+ visible = FALSE;
+ }
+ else
+ gtk_widget_hide (GTK_WIDGET (cur->data));
+ break;
+ }
+ }
+ else if (gtk_widget_get_visible (cur->data))
+ {
+ last = NULL;
+
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
+ if (GTK_IS_TEAROFF_MENU_ITEM (cur->data) || cur->data == filler)
+ visible = FALSE;
+ else
+ {
+ visible = TRUE;
+ empty = FALSE;
+ }
+
+G_GNUC_END_IGNORE_DEPRECATIONS
+
+ }
+
+ cur = cur->next;
+ }
+
+ if (last)
+ gtk_widget_hide (GTK_WIDGET (last->data));
+
+ if (GTK_IS_MENU (parent))
+ {
+ GtkWidget *item;
+
+ item = gtk_menu_get_attach_widget (GTK_MENU (parent));
+ if (GTK_IS_MENU_ITEM (item))
+ _gtk_action_sync_menu_visible (NULL, item, empty);
+ if (GTK_IS_WIDGET (filler))
+ {
+ if (empty)
+ gtk_widget_show (filler);
+ else
+ gtk_widget_hide (filler);
+ }
+ }
+
+ g_list_free (children);
+ }
+}
+
+static void
+update_node (GtkUIManager *manager,
+ GNode *node,
+ gboolean in_popup,
+ gboolean popup_accels)
+{
+ Node *info;
+ GNode *child;
+ GtkAction *action;
+ const gchar *action_name;
+ NodeUIReference *ref;
+
+#ifdef DEBUG_UI_MANAGER
+ GList *tmp;
+#endif
+
+ g_return_if_fail (node != NULL);
+ g_return_if_fail (NODE_INFO (node) != NULL);
+
+ info = NODE_INFO (node);
+
+ if (!info->dirty)
+ return;
+
+ if (info->type == NODE_TYPE_POPUP)
+ {
+ in_popup = TRUE;
+ popup_accels = info->popup_accels;
+ }
+
+#ifdef DEBUG_UI_MANAGER
+ g_print ("update_node name=%s dirty=%d popup %d (",
+ info->name, info->dirty, in_popup);
+ for (tmp = info->uifiles; tmp != NULL; tmp = tmp->next)
+ {
+ NodeUIReference *ref = tmp->data;
+ g_print("%s:%u", g_quark_to_string (ref->action_quark), ref->merge_id);
+ if (tmp->next)
+ g_print (", ");
+ }
+ g_print (")\n");
+#endif
+
+ if (info->uifiles == NULL) {
+ /* We may need to remove this node.
+ * This must be done in post order
+ */
+ goto recurse_children;
+ }
+
+ ref = info->uifiles->data;
+ action_name = g_quark_to_string (ref->action_quark);
+ action = get_action_by_name (manager, action_name);
+
+ info->dirty = FALSE;
+
+ /* Check if the node doesn't have an action and must have an action */
+ if (action == NULL &&
+ info->type != NODE_TYPE_ROOT &&
+ info->type != NODE_TYPE_MENUBAR &&
+ info->type != NODE_TYPE_TOOLBAR &&
+ info->type != NODE_TYPE_POPUP &&
+ info->type != NODE_TYPE_SEPARATOR &&
+ info->type != NODE_TYPE_MENU_PLACEHOLDER &&
+ info->type != NODE_TYPE_TOOLBAR_PLACEHOLDER)
+ {
+ g_warning ("%s: missing action %s", info->name, action_name);
+
+ return;
+ }
+
+ if (action)
+ gtk_action_set_accel_group (action, manager->private_data->accel_group);
+
+ /* If the widget already has a proxy and the action hasn't changed, then
+ * we only have to update the tearoff menu items.
+ */
+ if (info->proxy != NULL && action == info->action)
+ {
+ if (info->type == NODE_TYPE_MENU)
+ {
+ GtkWidget *menu;
+ GList *siblings;
+
+ if (GTK_IS_MENU (info->proxy))
+ menu = info->proxy;
+ else
+ menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (info->proxy));
+ siblings = gtk_container_get_children (GTK_CONTAINER (menu));
+
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
+ if (siblings != NULL && GTK_IS_TEAROFF_MENU_ITEM (siblings->data))
+ {
+ if (manager->private_data->add_tearoffs && !in_popup)
+ gtk_widget_show (GTK_WIDGET (siblings->data));
+ else
+ gtk_widget_hide (GTK_WIDGET (siblings->data));
+ }
+
+G_GNUC_END_IGNORE_DEPRECATIONS
+
+ g_list_free (siblings);
+ }
+
+ goto recurse_children;
+ }
+
+ switch (info->type)
+ {
+ case NODE_TYPE_MENUBAR:
+ if (info->proxy == NULL)
+ {
+ info->proxy = gtk_menu_bar_new ();
+ g_object_ref_sink (info->proxy);
+ gtk_widget_set_name (info->proxy, info->name);
+ gtk_widget_show (info->proxy);
+ g_signal_emit (manager, ui_manager_signals[ADD_WIDGET], 0, info->proxy);
+ }
+ break;
+ case NODE_TYPE_POPUP:
+ if (info->proxy == NULL)
+ {
+ info->proxy = gtk_menu_new ();
+ g_object_ref_sink (info->proxy);
+ }
+ gtk_widget_set_name (info->proxy, info->name);
+ break;
+ case NODE_TYPE_MENU:
+ {
+ GtkWidget *prev_submenu = NULL;
+ GtkWidget *menu = NULL;
+ GList *siblings;
+
+ /* remove the proxy if it is of the wrong type ... */
+ if (info->proxy &&
+ G_OBJECT_TYPE (info->proxy) != GTK_ACTION_GET_CLASS (action)->menu_item_type)
+ {
+ if (GTK_IS_MENU_ITEM (info->proxy))
+ {
+ prev_submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (info->proxy));
+ if (prev_submenu)
+ {
+ g_object_ref (prev_submenu);
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (info->proxy), NULL);
+ }
+ }
+
+ gtk_activatable_set_related_action (GTK_ACTIVATABLE (info->proxy), NULL);
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)),
+ info->proxy);
+ g_object_unref (info->proxy);
+ info->proxy = NULL;
+ }
+
+ /* create proxy if needed ... */
+ if (info->proxy == NULL)
+ {
+ /* ... if the action already provides a menu, then use
+ * that menu instead of creating an empty one
+ */
+ if ((NODE_INFO (node->parent)->type == NODE_TYPE_TOOLITEM ||
+ NODE_INFO (node->parent)->type == NODE_TYPE_MENUITEM) &&
+ GTK_ACTION_GET_CLASS (action)->create_menu)
+ {
+ menu = gtk_action_create_menu (action);
+ }
+
+ if (!menu)
+ {
+ GtkWidget *tearoff;
+ GtkWidget *filler;
+
+ menu = gtk_menu_new ();
+ gtk_widget_set_name (menu, info->name);
+
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+ tearoff = gtk_tearoff_menu_item_new ();
+G_GNUC_END_IGNORE_DEPRECATIONS
+
+ gtk_widget_set_no_show_all (tearoff, TRUE);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), tearoff);
+ filler = gtk_menu_item_new_with_label (_("Empty"));
+ g_object_set_data (G_OBJECT (filler),
+ I_("gtk-empty-menu-item"),
+ GINT_TO_POINTER (TRUE));
+ gtk_widget_set_sensitive (filler, FALSE);
+ gtk_widget_set_no_show_all (filler, TRUE);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), filler);
+ }
+
+ if (NODE_INFO (node->parent)->type == NODE_TYPE_TOOLITEM)
+ {
+ info->proxy = menu;
+ g_object_ref_sink (info->proxy);
+ gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (NODE_INFO (node->parent)->proxy),
+ menu);
+ }
+ else
+ {
+ GtkWidget *menushell;
+ gint pos;
+
+ if (find_menu_position (node, &menushell, &pos))
+ {
+ info->proxy = gtk_action_create_menu_item (action);
+ g_object_ref_sink (info->proxy);
+ g_signal_connect (info->proxy, "notify::visible",
+ G_CALLBACK (update_smart_separators), NULL);
+ gtk_widget_set_name (info->proxy, info->name);
+
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (info->proxy), menu);
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menushell), info->proxy, pos);
+ }
+ }
+ }
+ else
+ gtk_activatable_set_related_action (GTK_ACTIVATABLE (info->proxy), action);
+
+ if (prev_submenu)
+ {
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (info->proxy),
+ prev_submenu);
+ g_object_unref (prev_submenu);
+ }
+
+ if (GTK_IS_MENU (info->proxy))
+ menu = info->proxy;
+ else
+ menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (info->proxy));
+
+ siblings = gtk_container_get_children (GTK_CONTAINER (menu));
+
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
+ if (siblings != NULL && GTK_IS_TEAROFF_MENU_ITEM (siblings->data))
+ {
+ if (manager->private_data->add_tearoffs && !in_popup)
+ gtk_widget_show (GTK_WIDGET (siblings->data));
+ else
+ gtk_widget_hide (GTK_WIDGET (siblings->data));
+ }
+
+G_GNUC_END_IGNORE_DEPRECATIONS
+
+ g_list_free (siblings);
+ }
+ break;
+ case NODE_TYPE_UNDECIDED:
+ g_warning ("found undecided node!");
+ break;
+ case NODE_TYPE_ROOT:
+ break;
+ case NODE_TYPE_TOOLBAR:
+ if (info->proxy == NULL)
+ {
+ info->proxy = gtk_toolbar_new ();
+ g_object_ref_sink (info->proxy);
+ gtk_widget_set_name (info->proxy, info->name);
+ gtk_widget_show (info->proxy);
+ g_signal_emit (manager, ui_manager_signals[ADD_WIDGET], 0, info->proxy);
+ }
+ break;
+ case NODE_TYPE_MENU_PLACEHOLDER:
+ /* create menu items for placeholders if necessary ... */
+ if (!GTK_IS_SEPARATOR_MENU_ITEM (info->proxy) ||
+ !GTK_IS_SEPARATOR_MENU_ITEM (info->extra))
+ {
+ if (info->proxy)
+ {
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)),
+ info->proxy);
+ g_object_unref (info->proxy);
+ info->proxy = NULL;
+ }
+ if (info->extra)
+ {
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->extra)),
+ info->extra);
+ g_object_unref (info->extra);
+ info->extra = NULL;
+ }
+ }
+ if (info->proxy == NULL)
+ {
+ GtkWidget *menushell;
+ gint pos;
+
+ if (find_menu_position (node, &menushell, &pos))
+ {
+ info->proxy = gtk_separator_menu_item_new ();
+ g_object_ref_sink (info->proxy);
+ g_object_set_data (G_OBJECT (info->proxy),
+ I_("gtk-separator-mode"),
+ GINT_TO_POINTER (SEPARATOR_MODE_HIDDEN));
+ gtk_widget_set_no_show_all (info->proxy, TRUE);
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menushell),
+ NODE_INFO (node)->proxy, pos);
+
+ info->extra = gtk_separator_menu_item_new ();
+ g_object_ref_sink (info->extra);
+ g_object_set_data (G_OBJECT (info->extra),
+ I_("gtk-separator-mode"),
+ GINT_TO_POINTER (SEPARATOR_MODE_HIDDEN));
+ gtk_widget_set_no_show_all (info->extra, TRUE);
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menushell),
+ NODE_INFO (node)->extra, pos + 1);
+ }
+ }
+ break;
+ case NODE_TYPE_TOOLBAR_PLACEHOLDER:
+ /* create toolbar items for placeholders if necessary ... */
+ if (!GTK_IS_SEPARATOR_TOOL_ITEM (info->proxy) ||
+ !GTK_IS_SEPARATOR_TOOL_ITEM (info->extra))
+ {
+ if (info->proxy)
+ {
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)),
+ info->proxy);
+ g_object_unref (info->proxy);
+ info->proxy = NULL;
+ }
+ if (info->extra)
+ {
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->extra)),
+ info->extra);
+ g_object_unref (info->extra);
+ info->extra = NULL;
+ }
+ }
+ if (info->proxy == NULL)
+ {
+ GtkWidget *toolbar;
+ gint pos;
+ GtkToolItem *item;
+
+ if (find_toolbar_position (node, &toolbar, &pos))
+ {
+ item = gtk_separator_tool_item_new ();
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, pos);
+ info->proxy = GTK_WIDGET (item);
+ g_object_ref_sink (info->proxy);
+ g_object_set_data (G_OBJECT (info->proxy),
+ I_("gtk-separator-mode"),
+ GINT_TO_POINTER (SEPARATOR_MODE_HIDDEN));
+ gtk_widget_set_no_show_all (info->proxy, TRUE);
+
+ item = gtk_separator_tool_item_new ();
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, pos+1);
+ info->extra = GTK_WIDGET (item);
+ g_object_ref_sink (info->extra);
+ g_object_set_data (G_OBJECT (info->extra),
+ I_("gtk-separator-mode"),
+ GINT_TO_POINTER (SEPARATOR_MODE_HIDDEN));
+ gtk_widget_set_no_show_all (info->extra, TRUE);
+ }
+ }
+ break;
+ case NODE_TYPE_MENUITEM:
+ /* remove the proxy if it is of the wrong type ... */
+ if (info->proxy &&
+ G_OBJECT_TYPE (info->proxy) != GTK_ACTION_GET_CLASS (action)->menu_item_type)
+ {
+ g_signal_handlers_disconnect_by_func (info->proxy,
+ G_CALLBACK (update_smart_separators),
+ NULL);
+ gtk_activatable_set_related_action (GTK_ACTIVATABLE (info->proxy), NULL);
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)),
+ info->proxy);
+ g_object_unref (info->proxy);
+ info->proxy = NULL;
+ }
+ /* create proxy if needed ... */
+ if (info->proxy == NULL)
+ {
+ GtkWidget *menushell;
+ gint pos;
+
+ if (find_menu_position (node, &menushell, &pos))
+ {
+ info->proxy = gtk_action_create_menu_item (action);
+ g_object_ref_sink (info->proxy);
+ gtk_widget_set_name (info->proxy, info->name);
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+
+ if (info->always_show_image_set &&
+ GTK_IS_IMAGE_MENU_ITEM (info->proxy))
+ gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (info->proxy),
+ info->always_show_image);
+
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menushell),
+ info->proxy, pos);
+ }
+ }
+ else
+ {
+ g_signal_handlers_disconnect_by_func (info->proxy,
+ G_CALLBACK (update_smart_separators),
+ NULL);
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (info->proxy), NULL);
+ gtk_activatable_set_related_action (GTK_ACTIVATABLE (info->proxy), action);
+ }
+
+ if (info->proxy)
+ {
+ g_signal_connect (info->proxy, "notify::visible",
+ G_CALLBACK (update_smart_separators), NULL);
+ if (in_popup && !popup_accels)
+ {
+ /* don't show accels in popups */
+ GtkWidget *child = gtk_bin_get_child (GTK_BIN (info->proxy));
+ if (GTK_IS_ACCEL_LABEL (child))
+ g_object_set (child, "accel-closure", NULL, NULL);
+ }
+ }
+
+ break;
+ case NODE_TYPE_TOOLITEM:
+ /* remove the proxy if it is of the wrong type ... */
+ if (info->proxy &&
+ G_OBJECT_TYPE (info->proxy) != GTK_ACTION_GET_CLASS (action)->toolbar_item_type)
+ {
+ g_signal_handlers_disconnect_by_func (info->proxy,
+ G_CALLBACK (update_smart_separators),
+ NULL);
+ gtk_activatable_set_related_action (GTK_ACTIVATABLE (info->proxy), NULL);
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)),
+ info->proxy);
+ g_object_unref (info->proxy);
+ info->proxy = NULL;
+ }
+ /* create proxy if needed ... */
+ if (info->proxy == NULL)
+ {
+ GtkWidget *toolbar;
+ gint pos;
+
+ if (find_toolbar_position (node, &toolbar, &pos))
+ {
+ info->proxy = gtk_action_create_tool_item (action);
+ g_object_ref_sink (info->proxy);
+ gtk_widget_set_name (info->proxy, info->name);
+
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar),
+ GTK_TOOL_ITEM (info->proxy), pos);
+ }
+ }
+ else
+ {
+ g_signal_handlers_disconnect_by_func (info->proxy,
+ G_CALLBACK (update_smart_separators),
+ NULL);
+ gtk_activatable_set_related_action (GTK_ACTIVATABLE (info->proxy), action);
+ }
+
+ if (info->proxy)
+ {
+ g_signal_connect (info->proxy, "notify::visible",
+ G_CALLBACK (update_smart_separators), NULL);
+ }
+ break;
+ case NODE_TYPE_SEPARATOR:
+ if (NODE_INFO (node->parent)->type == NODE_TYPE_TOOLBAR ||
+ NODE_INFO (node->parent)->type == NODE_TYPE_TOOLBAR_PLACEHOLDER)
+ {
+ GtkWidget *toolbar;
+ gint pos;
+ gint separator_mode;
+ GtkToolItem *item;
+
+ if (GTK_IS_SEPARATOR_TOOL_ITEM (info->proxy))
+ {
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)),
+ info->proxy);
+ g_object_unref (info->proxy);
+ info->proxy = NULL;
+ }
+
+ if (find_toolbar_position (node, &toolbar, &pos))
+ {
+ item = gtk_separator_tool_item_new ();
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, pos);
+ info->proxy = GTK_WIDGET (item);
+ g_object_ref_sink (info->proxy);
+ gtk_widget_set_no_show_all (info->proxy, TRUE);
+ if (info->expand)
+ {
+ gtk_tool_item_set_expand (GTK_TOOL_ITEM (item), TRUE);
+ gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (item), FALSE);
+ separator_mode = SEPARATOR_MODE_VISIBLE;
+ }
+ else
+ separator_mode = SEPARATOR_MODE_SMART;
+
+ g_object_set_data (G_OBJECT (info->proxy),
+ I_("gtk-separator-mode"),
+ GINT_TO_POINTER (separator_mode));
+ gtk_widget_show (info->proxy);
+ }
+ }
+ else
+ {
+ GtkWidget *menushell;
+ gint pos;
+
+ if (GTK_IS_SEPARATOR_MENU_ITEM (info->proxy))
+ {
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)),
+ info->proxy);
+ g_object_unref (info->proxy);
+ info->proxy = NULL;
+ }
+
+ if (find_menu_position (node, &menushell, &pos))
+ {
+ info->proxy = gtk_separator_menu_item_new ();
+ g_object_ref_sink (info->proxy);
+ gtk_widget_set_no_show_all (info->proxy, TRUE);
+ g_object_set_data (G_OBJECT (info->proxy),
+ I_("gtk-separator-mode"),
+ GINT_TO_POINTER (SEPARATOR_MODE_SMART));
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menushell),
+ info->proxy, pos);
+ gtk_widget_show (info->proxy);
+ }
+ }
+ break;
+ case NODE_TYPE_ACCELERATOR:
+ gtk_action_connect_accelerator (action);
+ break;
+ }
+
+ if (action)
+ g_object_ref (action);
+ if (info->action)
+ g_object_unref (info->action);
+ info->action = action;
+
+ recurse_children:
+ /* process children */
+ child = node->children;
+ while (child)
+ {
+ GNode *current;
+
+ current = child;
+ child = current->next;
+ update_node (manager, current, in_popup, popup_accels);
+ }
+
+ if (info->proxy)
+ {
+ if (info->type == NODE_TYPE_MENU && GTK_IS_MENU_ITEM (info->proxy))
+ update_smart_separators (gtk_menu_item_get_submenu (GTK_MENU_ITEM (info->proxy)));
+ else if (info->type == NODE_TYPE_MENU ||
+ info->type == NODE_TYPE_TOOLBAR ||
+ info->type == NODE_TYPE_POPUP)
+ update_smart_separators (info->proxy);
+ }
+
+ /* handle cleanup of dead nodes */
+ if (node->children == NULL && info->uifiles == NULL)
+ {
+ if (info->proxy)
+ gtk_widget_destroy (info->proxy);
+ if (info->extra)
+ gtk_widget_destroy (info->extra);
+ if (info->type == NODE_TYPE_ACCELERATOR && info->action != NULL)
+ gtk_action_disconnect_accelerator (info->action);
+ free_node (node);
+ g_node_destroy (node);
+ }
+}
+
+static gboolean
+do_updates (GtkUIManager *manager)
+{
+ /* this function needs to check through the tree for dirty nodes.
+ * For such nodes, it needs to do the following:
+ *
+ * 1) check if they are referenced by any loaded UI files anymore.
+ * In which case, the proxy widget should be destroyed, unless
+ * there are any subnodes.
+ *
+ * 2) lookup the action for this node again. If it is different to
+ * the current one (or if no previous action has been looked up),
+ * the proxy is reconnected to the new action (or a new proxy widget
+ * is created and added to the parent container).
+ */
+ update_node (manager, manager->private_data->root_node, FALSE, FALSE);
+
+ manager->private_data->update_tag = 0;
+
+ return FALSE;
+}
+
+static gboolean
+do_updates_idle (GtkUIManager *manager)
+{
+ do_updates (manager);
+
+ return FALSE;
+}
+
+static void
+queue_update (GtkUIManager *manager)
+{
+ if (manager->private_data->update_tag != 0)
+ return;
+
+ manager->private_data->update_tag = gdk_threads_add_idle (
+ (GSourceFunc)do_updates_idle,
+ manager);
+}
+
+
+/**
+ * gtk_ui_manager_ensure_update:
+ * @manager: a #GtkUIManager
+ *
+ * Makes sure that all pending updates to the UI have been completed.
+ *
+ * This may occasionally be necessary, since #GtkUIManager updates the
+ * UI in an idle function. A typical example where this function is
+ * useful is to enforce that the menubar and toolbar have been added to
+ * the main window before showing it:
+ * |[
+ * gtk_container_add (GTK_CONTAINER (window), vbox);
+ * g_signal_connect (merge, "add-widget",
+ * G_CALLBACK (add_widget), vbox);
+ * gtk_ui_manager_add_ui_from_file (merge, "my-menus");
+ * gtk_ui_manager_add_ui_from_file (merge, "my-toolbars");
+ * gtk_ui_manager_ensure_update (merge);
+ * gtk_widget_show (window);
+ * ]|
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+void
+gtk_ui_manager_ensure_update (GtkUIManager *manager)
+{
+ if (manager->private_data->update_tag != 0)
+ {
+ g_source_remove (manager->private_data->update_tag);
+ do_updates (manager);
+ }
+}
+
+static gboolean
+dirty_traverse_func (GNode *node,
+ gpointer data)
+{
+ NODE_INFO (node)->dirty = TRUE;
+ return FALSE;
+}
+
+static void
+dirty_all_nodes (GtkUIManager *manager)
+{
+ g_node_traverse (manager->private_data->root_node,
+ G_PRE_ORDER, G_TRAVERSE_ALL, -1,
+ dirty_traverse_func, NULL);
+ queue_update (manager);
+}
+
+static void
+mark_node_dirty (GNode *node)
+{
+ GNode *p;
+
+ /* FIXME could optimize this */
+ for (p = node; p; p = p->parent)
+ NODE_INFO (p)->dirty = TRUE;
+}
+
+static const gchar *
+open_tag_format (NodeType type)
+{
+ switch (type)
+ {
+ case NODE_TYPE_UNDECIDED: return "%*s<UNDECIDED";
+ case NODE_TYPE_ROOT: return "%*s<ui";
+ case NODE_TYPE_MENUBAR: return "%*s<menubar";
+ case NODE_TYPE_MENU: return "%*s<menu";
+ case NODE_TYPE_TOOLBAR: return "%*s<toolbar";
+ case NODE_TYPE_MENU_PLACEHOLDER:
+ case NODE_TYPE_TOOLBAR_PLACEHOLDER: return "%*s<placeholder";
+ case NODE_TYPE_POPUP: return "%*s<popup";
+ case NODE_TYPE_MENUITEM: return "%*s<menuitem";
+ case NODE_TYPE_TOOLITEM: return "%*s<toolitem";
+ case NODE_TYPE_SEPARATOR: return "%*s<separator";
+ case NODE_TYPE_ACCELERATOR: return "%*s<accelerator";
+ default: return NULL;
+ }
+}
+
+static const gchar *
+close_tag_format (NodeType type)
+{
+ switch (type)
+ {
+ case NODE_TYPE_UNDECIDED: return "%*s</UNDECIDED>\n";
+ case NODE_TYPE_ROOT: return "%*s</ui>\n";
+ case NODE_TYPE_MENUBAR: return "%*s</menubar>\n";
+ case NODE_TYPE_MENU: return "%*s</menu>\n";
+ case NODE_TYPE_TOOLBAR: return "%*s</toolbar>\n";
+ case NODE_TYPE_MENU_PLACEHOLDER:
+ case NODE_TYPE_TOOLBAR_PLACEHOLDER: return "%*s</placeholder>\n";
+ case NODE_TYPE_POPUP: return "%*s</popup>\n";
+ default: return NULL;
+ }
+}
+
+static void
+print_node (GtkUIManager *manager,
+ GNode *node,
+ gint indent_level,
+ GString *buffer)
+{
+ Node *mnode;
+ GNode *child;
+ const gchar *open_fmt;
+ const gchar *close_fmt;
+
+ mnode = node->data;
+
+ open_fmt = open_tag_format (mnode->type);
+ close_fmt = close_tag_format (mnode->type);
+
+ g_string_append_printf (buffer, open_fmt, indent_level, "");
+
+ if (mnode->type != NODE_TYPE_ROOT)
+ {
+ if (mnode->name)
+ g_string_append_printf (buffer, " name=\"%s\"", mnode->name);
+
+ if (mnode->action_name)
+ g_string_append_printf (buffer, " action=\"%s\"",
+ g_quark_to_string (mnode->action_name));
+ }
+
+ g_string_append (buffer, close_fmt ? ">\n" : "/>\n");
+
+ for (child = node->children; child != NULL; child = child->next)
+ print_node (manager, child, indent_level + 2, buffer);
+
+ if (close_fmt)
+ g_string_append_printf (buffer, close_fmt, indent_level, "");
+}
+
+static gboolean
+gtk_ui_manager_buildable_custom_tag_start (GtkBuildable *buildable,
+ GtkBuilder *builder,
+ GObject *child,
+ const gchar *tagname,
+ GMarkupParser *parser,
+ gpointer *data)
+{
+ if (child)
+ return FALSE;
+
+ if (strcmp (tagname, "ui") == 0)
+ {
+ ParseContext *ctx;
+
+ ctx = g_new0 (ParseContext, 1);
+ ctx->state = STATE_START;
+ ctx->manager = GTK_UI_MANAGER (buildable);
+ ctx->current = NULL;
+ ctx->merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (buildable));
+
+ *data = ctx;
+ *parser = ui_parser;
+
+ return TRUE;
+ }
+
+ return FALSE;
+
+}
+
+static void
+gtk_ui_manager_buildable_custom_tag_end (GtkBuildable *buildable,
+ GtkBuilder *builder,
+ GObject *child,
+ const gchar *tagname,
+ gpointer *data)
+{
+ queue_update (GTK_UI_MANAGER (buildable));
+ g_object_notify (G_OBJECT (buildable), "ui");
+ g_free (data);
+}
+
+/**
+ * gtk_ui_manager_get_ui:
+ * @manager: a #GtkUIManager
+ *
+ * Creates a <link linkend="XML-UI">UI definition</link> of the merged UI.
+ *
+ * Return value: A newly allocated string containing an XML representation of
+ * the merged UI.
+ *
+ * Since: 2.4
+ *
+ * Deprecated: 3.10
+ **/
+gchar *
+gtk_ui_manager_get_ui (GtkUIManager *manager)
+{
+ GString *buffer;
+
+ buffer = g_string_new (NULL);
+
+ gtk_ui_manager_ensure_update (manager);
+
+ print_node (manager, manager->private_data->root_node, 0, buffer);
+
+ return g_string_free (buffer, FALSE);
+}
--- /dev/null
+/*
+ * GTK - The GIMP Toolkit
+ * Copyright (C) 1998, 1999 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Author: James Henstridge <james@daa.com.au>
+ *
+ * Modified by the GTK+ Team and others 2003. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __GTK_UI_MANAGER_H__
+#define __GTK_UI_MANAGER_H__
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#include <gtk/gtkaccelgroup.h>
+#include <gtk/gtkwidget.h>
+#include <gtk/deprecated/gtkaction.h>
+#include <gtk/deprecated/gtkactiongroup.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_UI_MANAGER (gtk_ui_manager_get_type ())
+#define GTK_UI_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_UI_MANAGER, GtkUIManager))
+#define GTK_UI_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_UI_MANAGER, GtkUIManagerClass))
+#define GTK_IS_UI_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_UI_MANAGER))
+#define GTK_IS_UI_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_UI_MANAGER))
+#define GTK_UI_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_UI_MANAGER, GtkUIManagerClass))
+
+typedef struct _GtkUIManager GtkUIManager;
+typedef struct _GtkUIManagerClass GtkUIManagerClass;
+typedef struct _GtkUIManagerPrivate GtkUIManagerPrivate;
+
+
+struct _GtkUIManager {
+ GObject parent;
+
+ /*< private >*/
+ GtkUIManagerPrivate *private_data;
+};
+
+struct _GtkUIManagerClass {
+ GObjectClass parent_class;
+
+ /* Signals */
+ void (* add_widget) (GtkUIManager *manager,
+ GtkWidget *widget);
+ void (* actions_changed) (GtkUIManager *manager);
+ void (* connect_proxy) (GtkUIManager *manager,
+ GtkAction *action,
+ GtkWidget *proxy);
+ void (* disconnect_proxy) (GtkUIManager *manager,
+ GtkAction *action,
+ GtkWidget *proxy);
+ void (* pre_activate) (GtkUIManager *manager,
+ GtkAction *action);
+ void (* post_activate) (GtkUIManager *manager,
+ GtkAction *action);
+
+ /* Virtual functions */
+ GtkWidget * (* get_widget) (GtkUIManager *manager,
+ const gchar *path);
+ GtkAction * (* get_action) (GtkUIManager *manager,
+ const gchar *path);
+
+ /* Padding for future expansion */
+ void (*_gtk_reserved1) (void);
+ void (*_gtk_reserved2) (void);
+ void (*_gtk_reserved3) (void);
+ void (*_gtk_reserved4) (void);
+};
+
+/**
+ * GtkUIManagerItemType:
+ * @GTK_UI_MANAGER_AUTO: Pick the type of the UI element according to context.
+ * @GTK_UI_MANAGER_MENUBAR: Create a menubar.
+ * @GTK_UI_MANAGER_MENU: Create a menu.
+ * @GTK_UI_MANAGER_TOOLBAR: Create a toolbar.
+ * @GTK_UI_MANAGER_PLACEHOLDER: Insert a placeholder.
+ * @GTK_UI_MANAGER_POPUP: Create a popup menu.
+ * @GTK_UI_MANAGER_MENUITEM: Create a menuitem.
+ * @GTK_UI_MANAGER_TOOLITEM: Create a toolitem.
+ * @GTK_UI_MANAGER_SEPARATOR: Create a separator.
+ * @GTK_UI_MANAGER_ACCELERATOR: Install an accelerator.
+ * @GTK_UI_MANAGER_POPUP_WITH_ACCELS: Same as %GTK_UI_MANAGER_POPUP, but the
+ * actions' accelerators are shown.
+ *
+ * These enumeration values are used by gtk_ui_manager_add_ui() to determine
+ * what UI element to create.
+ *
+ * Deprecated: 3.10
+ */
+typedef enum {
+ GTK_UI_MANAGER_AUTO = 0,
+ GTK_UI_MANAGER_MENUBAR = 1 << 0,
+ GTK_UI_MANAGER_MENU = 1 << 1,
+ GTK_UI_MANAGER_TOOLBAR = 1 << 2,
+ GTK_UI_MANAGER_PLACEHOLDER = 1 << 3,
+ GTK_UI_MANAGER_POPUP = 1 << 4,
+ GTK_UI_MANAGER_MENUITEM = 1 << 5,
+ GTK_UI_MANAGER_TOOLITEM = 1 << 6,
+ GTK_UI_MANAGER_SEPARATOR = 1 << 7,
+ GTK_UI_MANAGER_ACCELERATOR = 1 << 8,
+ GTK_UI_MANAGER_POPUP_WITH_ACCELS = 1 << 9
+} GtkUIManagerItemType;
+
+GDK_DEPRECATED_IN_3_10
+GType gtk_ui_manager_get_type (void) G_GNUC_CONST;
+GDK_DEPRECATED_IN_3_10
+GtkUIManager *gtk_ui_manager_new (void);
+GDK_DEPRECATED_IN_3_4
+void gtk_ui_manager_set_add_tearoffs (GtkUIManager *manager,
+ gboolean add_tearoffs);
+GDK_DEPRECATED_IN_3_4
+gboolean gtk_ui_manager_get_add_tearoffs (GtkUIManager *manager);
+
+GDK_DEPRECATED_IN_3_10
+void gtk_ui_manager_insert_action_group (GtkUIManager *manager,
+ GtkActionGroup *action_group,
+ gint pos);
+GDK_DEPRECATED_IN_3_10
+void gtk_ui_manager_remove_action_group (GtkUIManager *manager,
+ GtkActionGroup *action_group);
+GDK_DEPRECATED_IN_3_10
+GList *gtk_ui_manager_get_action_groups (GtkUIManager *manager);
+GDK_DEPRECATED_IN_3_10
+GtkAccelGroup *gtk_ui_manager_get_accel_group (GtkUIManager *manager);
+GDK_DEPRECATED_IN_3_10
+GtkWidget *gtk_ui_manager_get_widget (GtkUIManager *manager,
+ const gchar *path);
+GDK_DEPRECATED_IN_3_10
+GSList *gtk_ui_manager_get_toplevels (GtkUIManager *manager,
+ GtkUIManagerItemType types);
+GDK_DEPRECATED_IN_3_10
+GtkAction *gtk_ui_manager_get_action (GtkUIManager *manager,
+ const gchar *path);
+GDK_DEPRECATED_IN_3_10
+guint gtk_ui_manager_add_ui_from_string (GtkUIManager *manager,
+ const gchar *buffer,
+ gssize length,
+ GError **error);
+GDK_DEPRECATED_IN_3_10
+guint gtk_ui_manager_add_ui_from_file (GtkUIManager *manager,
+ const gchar *filename,
+ GError **error);
+GDK_DEPRECATED_IN_3_10
+guint gtk_ui_manager_add_ui_from_resource(GtkUIManager *manager,
+ const gchar *resource_path,
+ GError **error);
+GDK_DEPRECATED_IN_3_10
+void gtk_ui_manager_add_ui (GtkUIManager *manager,
+ guint merge_id,
+ const gchar *path,
+ const gchar *name,
+ const gchar *action,
+ GtkUIManagerItemType type,
+ gboolean top);
+GDK_DEPRECATED_IN_3_10
+void gtk_ui_manager_remove_ui (GtkUIManager *manager,
+ guint merge_id);
+GDK_DEPRECATED_IN_3_10
+gchar *gtk_ui_manager_get_ui (GtkUIManager *manager);
+GDK_DEPRECATED_IN_3_10
+void gtk_ui_manager_ensure_update (GtkUIManager *manager);
+GDK_DEPRECATED_IN_3_10
+guint gtk_ui_manager_new_merge_id (GtkUIManager *manager);
+
+G_END_DECLS
+
+#endif /* __GTK_UI_MANAGER_H__ */
#include <gtk/gtkaccellabel.h>
#include <gtk/gtkaccelmap.h>
#include <gtk/gtkaccessible.h>
-#include <gtk/gtkaction.h>
#include <gtk/gtkactionable.h>
-#include <gtk/gtkactiongroup.h>
-#include <gtk/gtkactivatable.h>
#include <gtk/gtkadjustment.h>
#include <gtk/gtkalignment.h>
#include <gtk/gtkappchooser.h>
#include <gtk/gtkframe.h>
#include <gtk/gtkgrid.h>
#include <gtk/gtkheaderbar.h>
-#include <gtk/gtkiconfactory.h>
#include <gtk/gtkicontheme.h>
#include <gtk/gtkiconview.h>
#include <gtk/gtkimage.h>
-#include <gtk/gtkimagemenuitem.h>
#include <gtk/gtkimcontext.h>
#include <gtk/gtkimcontextinfo.h>
#include <gtk/gtkimcontextsimple.h>
#include <gtk/gtkprintoperationpreview.h>
#include <gtk/gtkprintsettings.h>
#include <gtk/gtkprogressbar.h>
-#include <gtk/gtkradioaction.h>
#include <gtk/gtkradiobutton.h>
#include <gtk/gtkradiomenuitem.h>
#include <gtk/gtkradiotoolbutton.h>
#include <gtk/gtkrange.h>
-#include <gtk/gtkrecentaction.h>
#include <gtk/gtkrecentchooser.h>
#include <gtk/gtkrecentchooserdialog.h>
#include <gtk/gtkrecentchoosermenu.h>
#include <gtk/gtkstackswitcher.h>
#include <gtk/gtkstatusbar.h>
#include <gtk/gtkstatusicon.h>
-#include <gtk/gtkstock.h>
#include <gtk/gtkstylecontext.h>
#include <gtk/gtkstyleproperties.h>
#include <gtk/gtkstyleprovider.h>
#include <gtk/gtktexttagtable.h>
#include <gtk/gtktextview.h>
#include <gtk/gtkthemingengine.h>
-#include <gtk/gtktoggleaction.h>
#include <gtk/gtktogglebutton.h>
#include <gtk/gtktoggletoolbutton.h>
#include <gtk/gtktoolbar.h>
#include <gtk/gtktreeviewcolumn.h>
#include <gtk/gtktypebuiltins.h>
#include <gtk/gtktypes.h>
-#include <gtk/gtkuimanager.h>
#include <gtk/gtkversion.h>
#include <gtk/gtkviewport.h>
#include <gtk/gtkvolumebutton.h>
#include <gtk/gtkwindow.h>
#ifndef GTK_DISABLE_DEPRECATED
+#include <gtk/deprecated/gtkactivatable.h>
+#include <gtk/deprecated/gtkaction.h>
+#include <gtk/deprecated/gtkactiongroup.h>
#include <gtk/deprecated/gtkcolorsel.h>
#include <gtk/deprecated/gtkcolorseldialog.h>
#include <gtk/deprecated/gtkfontsel.h>
#include <gtk/deprecated/gtkhscale.h>
#include <gtk/deprecated/gtkhscrollbar.h>
#include <gtk/deprecated/gtkhseparator.h>
+#include <gtk/deprecated/gtkiconfactory.h>
+#include <gtk/deprecated/gtkimagemenuitem.h>
+#include <gtk/deprecated/gtkradioaction.h>
#include <gtk/deprecated/gtkrc.h>
+#include <gtk/deprecated/gtkrecentaction.h>
+#include <gtk/deprecated/gtkstock.h>
#include <gtk/deprecated/gtkstyle.h>
#include <gtk/deprecated/gtksymboliccolor.h>
#include <gtk/deprecated/gtktable.h>
#include <gtk/deprecated/gtktearoffmenuitem.h>
+#include <gtk/deprecated/gtktoggleaction.h>
+#include <gtk/deprecated/gtkuimanager.h>
#include <gtk/deprecated/gtkvbbox.h>
#include <gtk/deprecated/gtkvbox.h>
#include <gtk/deprecated/gtkvpaned.h>
#include "gtkorientable.h"
#include "gtkscrolledwindow.h"
#include "gtktextview.h"
-#include "gtkiconfactory.h"
+#include "deprecated/gtkiconfactory.h"
#include "gtkshow.h"
#include "gtkmain.h"
#include "gtkmessagedialog.h"
+++ /dev/null
-/*
- * GTK - The GIMP Toolkit
- * Copyright (C) 1998, 1999 Red Hat, Inc.
- * All rights reserved.
- *
- * This Library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This Library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Author: James Henstridge <james@daa.com.au>
- *
- * Modified by the GTK+ Team and others 2003. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-/**
- * SECTION:gtkaction
- * @Short_description: An action which can be triggered by a menu or toolbar item
- * @Title: GtkAction
- * @See_also: #GtkActionGroup, #GtkUIManager, #GtkActivatable
- *
- * Actions represent operations that the user can be perform, along with
- * some information how it should be presented in the interface. Each action
- * provides methods to create icons, menu items and toolbar items
- * representing itself.
- *
- * As well as the callback that is called when the action gets activated,
- * the following also gets associated with the action:
- * <itemizedlist>
- * <listitem><para>a name (not translated, for path lookup)</para></listitem>
- * <listitem><para>a label (translated, for display)</para></listitem>
- * <listitem><para>an accelerator</para></listitem>
- * <listitem><para>whether label indicates a stock id</para></listitem>
- * <listitem><para>a tooltip (optional, translated)</para></listitem>
- * <listitem><para>a toolbar label (optional, shorter than label)</para></listitem>
- * </itemizedlist>
- * The action will also have some state information:
- * <itemizedlist>
- * <listitem><para>visible (shown/hidden)</para></listitem>
- * <listitem><para>sensitive (enabled/disabled)</para></listitem>
- * </itemizedlist>
- * Apart from regular actions, there are <link linkend="GtkToggleAction">toggle
- * actions</link>, which can be toggled between two states and <link
- * linkend="GtkRadioAction">radio actions</link>, of which only one in a group
- * can be in the "active" state. Other actions can be implemented as #GtkAction
- * subclasses.
- *
- * Each action can have one or more proxy widgets. To act as an action proxy,
- * widget needs to implement #GtkActivatable interface. Proxies mirror the state
- * of the action and should change when the action's state changes. Properties
- * that are always mirrored by proxies are #GtkAction:sensitive and
- * #GtkAction:visible. #GtkAction:gicon, #GtkAction:icon-name, #GtkAction:label,
- * #GtkAction:short-label and #GtkAction:stock-id properties are only mirorred
- * if proxy widget has #GtkActivatable:use-action-appearance property set to
- * %TRUE.
- *
- * When the proxy is activated, it should activate its action.
- */
-
-#include "config.h"
-
-#define GDK_DISABLE_DEPRECATION_WARNINGS
-
-#include "gtkaction.h"
-#include "gtkactiongroup.h"
-#include "gtkaccellabel.h"
-#include "gtkbutton.h"
-#include "gtkiconfactory.h"
-#include "gtkimage.h"
-#include "gtkimagemenuitem.h"
-#include "gtkintl.h"
-#include "gtklabel.h"
-#include "gtkmarshalers.h"
-#include "gtkmenuitem.h"
-#include "gtkstock.h"
-#include "deprecated/gtktearoffmenuitem.h"
-#include "gtktoolbutton.h"
-#include "gtktoolbar.h"
-#include "gtkprivate.h"
-#include "gtkbuildable.h"
-#include "gtkactivatable.h"
-
-
-struct _GtkActionPrivate
-{
- const gchar *name; /* interned */
- gchar *label;
- gchar *short_label;
- gchar *tooltip;
- gchar *stock_id; /* stock icon */
- gchar *icon_name; /* themed icon */
- GIcon *gicon;
-
- guint sensitive : 1;
- guint visible : 1;
- guint label_set : 1; /* these two used so we can set label */
- guint short_label_set : 1; /* based on stock id */
- guint visible_horizontal : 1;
- guint visible_vertical : 1;
- guint is_important : 1;
- guint hide_if_empty : 1;
- guint visible_overflown : 1;
- guint always_show_image : 1;
- guint recursion_guard : 1;
- guint activate_blocked : 1;
-
- /* accelerator */
- guint accel_count;
- GtkAccelGroup *accel_group;
- GClosure *accel_closure;
- GQuark accel_quark;
-
- GtkActionGroup *action_group;
-
- /* list of proxy widgets */
- GSList *proxies;
-};
-
-enum
-{
- ACTIVATE,
- LAST_SIGNAL
-};
-
-enum
-{
- PROP_0,
- PROP_NAME,
- PROP_LABEL,
- PROP_SHORT_LABEL,
- PROP_TOOLTIP,
- PROP_STOCK_ID,
- PROP_ICON_NAME,
- PROP_GICON,
- PROP_VISIBLE_HORIZONTAL,
- PROP_VISIBLE_VERTICAL,
- PROP_VISIBLE_OVERFLOWN,
- PROP_IS_IMPORTANT,
- PROP_HIDE_IF_EMPTY,
- PROP_SENSITIVE,
- PROP_VISIBLE,
- PROP_ACTION_GROUP,
- PROP_ALWAYS_SHOW_IMAGE
-};
-
-/* GtkBuildable */
-static void gtk_action_buildable_init (GtkBuildableIface *iface);
-static void gtk_action_buildable_set_name (GtkBuildable *buildable,
- const gchar *name);
-static const gchar* gtk_action_buildable_get_name (GtkBuildable *buildable);
-
-G_DEFINE_TYPE_WITH_CODE (GtkAction, gtk_action, G_TYPE_OBJECT,
- G_ADD_PRIVATE (GtkAction)
- G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
- gtk_action_buildable_init))
-
-static void gtk_action_finalize (GObject *object);
-static void gtk_action_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gtk_action_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void gtk_action_set_action_group (GtkAction *action,
- GtkActionGroup *action_group);
-
-static GtkWidget *create_menu_item (GtkAction *action);
-static GtkWidget *create_tool_item (GtkAction *action);
-static void connect_proxy (GtkAction *action,
- GtkWidget *proxy);
-static void disconnect_proxy (GtkAction *action,
- GtkWidget *proxy);
-
-static void closure_accel_activate (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-
-static guint action_signals[LAST_SIGNAL] = { 0 };
-
-
-static void
-gtk_action_class_init (GtkActionClass *klass)
-{
- GObjectClass *gobject_class;
-
- gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->finalize = gtk_action_finalize;
- gobject_class->set_property = gtk_action_set_property;
- gobject_class->get_property = gtk_action_get_property;
-
- klass->activate = NULL;
-
- klass->create_menu_item = create_menu_item;
- klass->create_tool_item = create_tool_item;
- klass->create_menu = NULL;
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- klass->menu_item_type = GTK_TYPE_IMAGE_MENU_ITEM;
- G_GNUC_END_IGNORE_DEPRECATIONS;
- klass->toolbar_item_type = GTK_TYPE_TOOL_BUTTON;
- klass->connect_proxy = connect_proxy;
- klass->disconnect_proxy = disconnect_proxy;
-
- /**
- * GtkAction:name:
- *
- * A unique name for the action.
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_NAME,
- g_param_spec_string ("name",
- P_("Name"),
- P_("A unique name for the action."),
- NULL,
- GTK_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
-
- /**
- * GtkAction:label:
- *
- * The label used for menu items and buttons that activate
- * this action. If the label is %NULL, GTK+ uses the stock
- * label specified via the stock-id property.
- *
- * This is an appearance property and thus only applies if
- * #GtkActivatable:use-action-appearance is %TRUE.
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_LABEL,
- g_param_spec_string ("label",
- P_("Label"),
- P_("The label used for menu items and buttons "
- "that activate this action."),
- NULL,
- GTK_PARAM_READWRITE));
-
- /**
- * GtkAction:short-label:
- *
- * A shorter label that may be used on toolbar buttons.
- *
- * This is an appearance property and thus only applies if
- * #GtkActivatable:use-action-appearance is %TRUE.
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_SHORT_LABEL,
- g_param_spec_string ("short-label",
- P_("Short label"),
- P_("A shorter label that may be used on toolbar buttons."),
- NULL,
- GTK_PARAM_READWRITE));
-
-
- /**
- * GtkAction:tooltip:
- *
- * A tooltip for this action.
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_TOOLTIP,
- g_param_spec_string ("tooltip",
- P_("Tooltip"),
- P_("A tooltip for this action."),
- NULL,
- GTK_PARAM_READWRITE));
-
- /**
- * GtkAction:stock-id:
- *
- * The stock icon displayed in widgets representing this action.
- *
- * This is an appearance property and thus only applies if
- * #GtkActivatable:use-action-appearance is %TRUE.
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_STOCK_ID,
- g_param_spec_string ("stock-id",
- P_("Stock Icon"),
- P_("The stock icon displayed in widgets representing "
- "this action."),
- NULL,
- GTK_PARAM_READWRITE));
- /**
- * GtkAction:gicon:
- *
- * The #GIcon displayed in the #GtkAction.
- *
- * Note that the stock icon is preferred, if the #GtkAction:stock-id
- * property holds the id of an existing stock icon.
- *
- * This is an appearance property and thus only applies if
- * #GtkActivatable:use-action-appearance is %TRUE.
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_GICON,
- g_param_spec_object ("gicon",
- P_("GIcon"),
- P_("The GIcon being displayed"),
- G_TYPE_ICON,
- GTK_PARAM_READWRITE));
- /**
- * GtkAction:icon-name:
- *
- * The name of the icon from the icon theme.
- *
- * Note that the stock icon is preferred, if the #GtkAction:stock-id
- * property holds the id of an existing stock icon, and the #GIcon is
- * preferred if the #GtkAction:gicon property is set.
- *
- * This is an appearance property and thus only applies if
- * #GtkActivatable:use-action-appearance is %TRUE.
- *
- * Since: 2.10
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_ICON_NAME,
- g_param_spec_string ("icon-name",
- P_("Icon Name"),
- P_("The name of the icon from the icon theme"),
- NULL,
- GTK_PARAM_READWRITE));
-
- /**
- * GtkAction:visible-horizontal:
- *
- * Whether the toolbar item is visible when the toolbar is in a horizontal orientation.
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_VISIBLE_HORIZONTAL,
- g_param_spec_boolean ("visible-horizontal",
- P_("Visible when horizontal"),
- P_("Whether the toolbar item is visible when the toolbar "
- "is in a horizontal orientation."),
- TRUE,
- GTK_PARAM_READWRITE));
- /**
- * GtkAction:visible-overflown:
- *
- * When %TRUE, toolitem proxies for this action are represented in the
- * toolbar overflow menu.
- *
- * Since: 2.6
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_VISIBLE_OVERFLOWN,
- g_param_spec_boolean ("visible-overflown",
- P_("Visible when overflown"),
- P_("When TRUE, toolitem proxies for this action "
- "are represented in the toolbar overflow menu."),
- TRUE,
- GTK_PARAM_READWRITE));
-
- /**
- * GtkAction:visible-vertical:
- *
- * Whether the toolbar item is visible when the toolbar is in a vertical orientation.
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_VISIBLE_VERTICAL,
- g_param_spec_boolean ("visible-vertical",
- P_("Visible when vertical"),
- P_("Whether the toolbar item is visible when the toolbar "
- "is in a vertical orientation."),
- TRUE,
- GTK_PARAM_READWRITE));
- /**
- * GtkAction:is-important:
- *
- * Whether the action is considered important. When TRUE, toolitem
- * proxies for this action show text in GTK_TOOLBAR_BOTH_HORIZ mode.
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_IS_IMPORTANT,
- g_param_spec_boolean ("is-important",
- P_("Is important"),
- P_("Whether the action is considered important. "
- "When TRUE, toolitem proxies for this action "
- "show text in GTK_TOOLBAR_BOTH_HORIZ mode."),
- FALSE,
- GTK_PARAM_READWRITE));
- /**
- * GtkAction:hide-if-empty:
- *
- * When TRUE, empty menu proxies for this action are hidden.
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_HIDE_IF_EMPTY,
- g_param_spec_boolean ("hide-if-empty",
- P_("Hide if empty"),
- P_("When TRUE, empty menu proxies for this action are hidden."),
- TRUE,
- GTK_PARAM_READWRITE));
- /**
- * GtkAction:sensitive:
- *
- * Whether the action is enabled.
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_SENSITIVE,
- g_param_spec_boolean ("sensitive",
- P_("Sensitive"),
- P_("Whether the action is enabled."),
- TRUE,
- GTK_PARAM_READWRITE));
- /**
- * GtkAction:visible:
- *
- * Whether the action is visible.
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_VISIBLE,
- g_param_spec_boolean ("visible",
- P_("Visible"),
- P_("Whether the action is visible."),
- TRUE,
- GTK_PARAM_READWRITE));
- /**
- * GtkAction:action-group:
- *
- * The GtkActionGroup this GtkAction is associated with, or NULL
- * (for internal use).
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_ACTION_GROUP,
- g_param_spec_object ("action-group",
- P_("Action Group"),
- P_("The GtkActionGroup this GtkAction is associated with, or NULL (for internal use)."),
- GTK_TYPE_ACTION_GROUP,
- GTK_PARAM_READWRITE));
-
- /**
- * GtkAction:always-show-image:
- *
- * If %TRUE, the action's menu item proxies will always show their image, if available.
- *
- * Use this property if the menu item would be useless or hard to use
- * without their image.
- *
- * Since: 2.20
- *
- * Deprecated: 3.10
- **/
- g_object_class_install_property (gobject_class,
- PROP_ALWAYS_SHOW_IMAGE,
- g_param_spec_boolean ("always-show-image",
- P_("Always show image"),
- P_("Whether the image will always be shown"),
- FALSE,
- GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- /**
- * GtkAction::activate:
- * @action: the #GtkAction
- *
- * The "activate" signal is emitted when the action is activated.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
- action_signals[ACTIVATE] =
- g_signal_new (I_("activate"),
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
- G_STRUCT_OFFSET (GtkActionClass, activate), NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-
-static void
-gtk_action_init (GtkAction *action)
-{
- action->private_data = gtk_action_get_instance_private (action);
-
- action->private_data->name = NULL;
- action->private_data->label = NULL;
- action->private_data->short_label = NULL;
- action->private_data->tooltip = NULL;
- action->private_data->stock_id = NULL;
- action->private_data->icon_name = NULL;
- action->private_data->visible_horizontal = TRUE;
- action->private_data->visible_vertical = TRUE;
- action->private_data->visible_overflown = TRUE;
- action->private_data->is_important = FALSE;
- action->private_data->hide_if_empty = TRUE;
- action->private_data->always_show_image = FALSE;
- action->private_data->activate_blocked = FALSE;
-
- action->private_data->sensitive = TRUE;
- action->private_data->visible = TRUE;
-
- action->private_data->label_set = FALSE;
- action->private_data->short_label_set = FALSE;
-
- action->private_data->accel_count = 0;
- action->private_data->accel_group = NULL;
- action->private_data->accel_quark = 0;
- action->private_data->accel_closure =
- g_closure_new_object (sizeof (GClosure), G_OBJECT (action));
- g_closure_set_marshal (action->private_data->accel_closure,
- closure_accel_activate);
- g_closure_ref (action->private_data->accel_closure);
- g_closure_sink (action->private_data->accel_closure);
-
- action->private_data->action_group = NULL;
-
- action->private_data->proxies = NULL;
- action->private_data->gicon = NULL;
-}
-
-static void
-gtk_action_buildable_init (GtkBuildableIface *iface)
-{
- iface->set_name = gtk_action_buildable_set_name;
- iface->get_name = gtk_action_buildable_get_name;
-}
-
-static void
-gtk_action_buildable_set_name (GtkBuildable *buildable,
- const gchar *name)
-{
- GtkAction *action = GTK_ACTION (buildable);
-
- action->private_data->name = g_intern_string (name);
-}
-
-static const gchar *
-gtk_action_buildable_get_name (GtkBuildable *buildable)
-{
- GtkAction *action = GTK_ACTION (buildable);
-
- return action->private_data->name;
-}
-
-/**
- * gtk_action_new:
- * @name: A unique name for the action
- * @label: (allow-none): the label displayed in menu items and on buttons,
- * or %NULL
- * @tooltip: (allow-none): a tooltip for the action, or %NULL
- * @stock_id: (allow-none): the stock icon to display in widgets representing
- * the action, or %NULL
- *
- * Creates a new #GtkAction object. To add the action to a
- * #GtkActionGroup and set the accelerator for the action,
- * call gtk_action_group_add_action_with_accel().
- * See <xref linkend="XML-UI"/> for information on allowed action
- * names.
- *
- * Return value: a new #GtkAction
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-GtkAction *
-gtk_action_new (const gchar *name,
- const gchar *label,
- const gchar *tooltip,
- const gchar *stock_id)
-{
- g_return_val_if_fail (name != NULL, NULL);
-
- return g_object_new (GTK_TYPE_ACTION,
- "name", name,
- "label", label,
- "tooltip", tooltip,
- "stock-id", stock_id,
- NULL);
-}
-
-static void
-gtk_action_finalize (GObject *object)
-{
- GtkAction *action;
- action = GTK_ACTION (object);
-
- g_free (action->private_data->label);
- g_free (action->private_data->short_label);
- g_free (action->private_data->tooltip);
- g_free (action->private_data->stock_id);
- g_free (action->private_data->icon_name);
-
- if (action->private_data->gicon)
- g_object_unref (action->private_data->gicon);
-
- g_closure_unref (action->private_data->accel_closure);
- if (action->private_data->accel_group)
- g_object_unref (action->private_data->accel_group);
-
- G_OBJECT_CLASS (gtk_action_parent_class)->finalize (object);
-}
-
-static void
-gtk_action_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GtkAction *action;
-
- action = GTK_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_NAME:
- action->private_data->name = g_intern_string (g_value_get_string (value));
- break;
- case PROP_LABEL:
- gtk_action_set_label (action, g_value_get_string (value));
- break;
- case PROP_SHORT_LABEL:
- gtk_action_set_short_label (action, g_value_get_string (value));
- break;
- case PROP_TOOLTIP:
- gtk_action_set_tooltip (action, g_value_get_string (value));
- break;
- case PROP_STOCK_ID:
- gtk_action_set_stock_id (action, g_value_get_string (value));
- break;
- case PROP_GICON:
- gtk_action_set_gicon (action, g_value_get_object (value));
- break;
- case PROP_ICON_NAME:
- gtk_action_set_icon_name (action, g_value_get_string (value));
- break;
- case PROP_VISIBLE_HORIZONTAL:
- gtk_action_set_visible_horizontal (action, g_value_get_boolean (value));
- break;
- case PROP_VISIBLE_VERTICAL:
- gtk_action_set_visible_vertical (action, g_value_get_boolean (value));
- break;
- case PROP_VISIBLE_OVERFLOWN:
- action->private_data->visible_overflown = g_value_get_boolean (value);
- break;
- case PROP_IS_IMPORTANT:
- gtk_action_set_is_important (action, g_value_get_boolean (value));
- break;
- case PROP_HIDE_IF_EMPTY:
- action->private_data->hide_if_empty = g_value_get_boolean (value);
- break;
- case PROP_SENSITIVE:
- gtk_action_set_sensitive (action, g_value_get_boolean (value));
- break;
- case PROP_VISIBLE:
- gtk_action_set_visible (action, g_value_get_boolean (value));
- break;
- case PROP_ACTION_GROUP:
- gtk_action_set_action_group (action, g_value_get_object (value));
- break;
- case PROP_ALWAYS_SHOW_IMAGE:
- gtk_action_set_always_show_image (action, g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gtk_action_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GtkAction *action;
-
- action = GTK_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_NAME:
- g_value_set_static_string (value, action->private_data->name);
- break;
- case PROP_LABEL:
- g_value_set_string (value, action->private_data->label);
- break;
- case PROP_SHORT_LABEL:
- g_value_set_string (value, action->private_data->short_label);
- break;
- case PROP_TOOLTIP:
- g_value_set_string (value, action->private_data->tooltip);
- break;
- case PROP_STOCK_ID:
- g_value_set_string (value, action->private_data->stock_id);
- break;
- case PROP_ICON_NAME:
- g_value_set_string (value, action->private_data->icon_name);
- break;
- case PROP_GICON:
- g_value_set_object (value, action->private_data->gicon);
- break;
- case PROP_VISIBLE_HORIZONTAL:
- g_value_set_boolean (value, action->private_data->visible_horizontal);
- break;
- case PROP_VISIBLE_VERTICAL:
- g_value_set_boolean (value, action->private_data->visible_vertical);
- break;
- case PROP_VISIBLE_OVERFLOWN:
- g_value_set_boolean (value, action->private_data->visible_overflown);
- break;
- case PROP_IS_IMPORTANT:
- g_value_set_boolean (value, action->private_data->is_important);
- break;
- case PROP_HIDE_IF_EMPTY:
- g_value_set_boolean (value, action->private_data->hide_if_empty);
- break;
- case PROP_SENSITIVE:
- g_value_set_boolean (value, action->private_data->sensitive);
- break;
- case PROP_VISIBLE:
- g_value_set_boolean (value, action->private_data->visible);
- break;
- case PROP_ACTION_GROUP:
- g_value_set_object (value, action->private_data->action_group);
- break;
- case PROP_ALWAYS_SHOW_IMAGE:
- g_value_set_boolean (value, action->private_data->always_show_image);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static GtkWidget *
-create_menu_item (GtkAction *action)
-{
- GType menu_item_type;
-
- menu_item_type = GTK_ACTION_GET_CLASS (action)->menu_item_type;
-
- return g_object_new (menu_item_type, NULL);
-}
-
-static GtkWidget *
-create_tool_item (GtkAction *action)
-{
- GType toolbar_item_type;
-
- toolbar_item_type = GTK_ACTION_GET_CLASS (action)->toolbar_item_type;
-
- return g_object_new (toolbar_item_type, NULL);
-}
-
-static void
-remove_proxy (GtkAction *action,
- GtkWidget *proxy)
-{
- g_object_unref (proxy);
- action->private_data->proxies = g_slist_remove (action->private_data->proxies, proxy);
-}
-
-static void
-connect_proxy (GtkAction *action,
- GtkWidget *proxy)
-{
- action->private_data->proxies = g_slist_prepend (action->private_data->proxies, proxy);
-
- g_object_ref_sink (proxy);
-
- if (action->private_data->action_group)
- _gtk_action_group_emit_connect_proxy (action->private_data->action_group, action, proxy);
-
-}
-
-static void
-disconnect_proxy (GtkAction *action,
- GtkWidget *proxy)
-{
- remove_proxy (action, proxy);
-
- if (action->private_data->action_group)
- _gtk_action_group_emit_disconnect_proxy (action->private_data->action_group, action, proxy);
-}
-
-/**
- * _gtk_action_sync_menu_visible:
- * @action: (allow-none): a #GtkAction, or %NULL to determine the action from @proxy
- * @proxy: a proxy menu item
- * @empty: whether the submenu attached to @proxy is empty
- *
- * Updates the visibility of @proxy from the visibility of @action
- * according to the following rules:
- * <itemizedlist>
- * <listitem><para>if @action is invisible, @proxy is too
- * </para></listitem>
- * <listitem><para>if @empty is %TRUE, hide @proxy unless the "hide-if-empty"
- * property of @action indicates otherwise
- * </para></listitem>
- * </itemizedlist>
- *
- * This function is used in the implementation of #GtkUIManager.
- *
- * Deprecated: 3.10
- **/
-void
-_gtk_action_sync_menu_visible (GtkAction *action,
- GtkWidget *proxy,
- gboolean empty)
-{
- gboolean visible = TRUE;
- gboolean hide_if_empty = TRUE;
-
- g_return_if_fail (GTK_IS_MENU_ITEM (proxy));
- g_return_if_fail (action == NULL || GTK_IS_ACTION (action));
-
- if (action == NULL)
- action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy));
-
- if (action)
- {
- /* a GtkMenu for a <popup/> doesn't have to have an action */
- visible = gtk_action_is_visible (action);
- hide_if_empty = action->private_data->hide_if_empty;
- }
-
- if (visible && !(empty && hide_if_empty))
- gtk_widget_show (proxy);
- else
- gtk_widget_hide (proxy);
-}
-
-void
-_gtk_action_emit_activate (GtkAction *action)
-{
- GtkActionGroup *group = action->private_data->action_group;
-
- if (group != NULL)
- {
- g_object_ref (action);
- g_object_ref (group);
- _gtk_action_group_emit_pre_activate (group, action);
- }
-
- g_signal_emit (action, action_signals[ACTIVATE], 0);
-
- if (group != NULL)
- {
- _gtk_action_group_emit_post_activate (group, action);
- g_object_unref (group);
- g_object_unref (action);
- }
-}
-
-/**
- * gtk_action_activate:
- * @action: the action object
- *
- * Emits the "activate" signal on the specified action, if it isn't
- * insensitive. This gets called by the proxy widgets when they get
- * activated.
- *
- * It can also be used to manually activate an action.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-void
-gtk_action_activate (GtkAction *action)
-{
- g_return_if_fail (GTK_IS_ACTION (action));
-
- if (action->private_data->activate_blocked)
- return;
-
- if (gtk_action_is_sensitive (action))
- _gtk_action_emit_activate (action);
-}
-
-/**
- * gtk_action_block_activate:
- * @action: a #GtkAction
- *
- * Disable activation signals from the action
- *
- * This is needed when updating the state of your proxy
- * #GtkActivatable widget could result in calling gtk_action_activate(),
- * this is a convenience function to avoid recursing in those
- * cases (updating toggle state for instance).
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-void
-gtk_action_block_activate (GtkAction *action)
-{
- g_return_if_fail (GTK_IS_ACTION (action));
-
- action->private_data->activate_blocked = TRUE;
-}
-
-/**
- * gtk_action_unblock_activate:
- * @action: a #GtkAction
- *
- * Reenable activation signals from the action
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-void
-gtk_action_unblock_activate (GtkAction *action)
-{
- g_return_if_fail (GTK_IS_ACTION (action));
-
- action->private_data->activate_blocked = FALSE;
-}
-
-/**
- * gtk_action_create_icon:
- * @action: the action object
- * @icon_size: (type int): the size of the icon that should be created.
- *
- * This function is intended for use by action implementations to
- * create icons displayed in the proxy widgets.
- *
- * Returns: (transfer none): a widget that displays the icon for this action.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-GtkWidget *
-gtk_action_create_icon (GtkAction *action, GtkIconSize icon_size)
-{
- GtkWidget *widget = NULL;
-
- g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-
- if (action->private_data->stock_id &&
- gtk_icon_factory_lookup_default (action->private_data->stock_id))
- widget = gtk_image_new_from_stock (action->private_data->stock_id, icon_size);
- else if (action->private_data->gicon)
- widget = gtk_image_new_from_gicon (action->private_data->gicon, icon_size);
- else if (action->private_data->icon_name)
- widget = gtk_image_new_from_icon_name (action->private_data->icon_name, icon_size);
-
- G_GNUC_END_IGNORE_DEPRECATIONS;
-
- return widget;
-}
-
-/**
- * gtk_action_create_menu_item:
- * @action: the action object
- *
- * Creates a menu item widget that proxies for the given action.
- *
- * Returns: (transfer none): a menu item connected to the action.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-GtkWidget *
-gtk_action_create_menu_item (GtkAction *action)
-{
- GtkWidget *menu_item;
-
- g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
-
- menu_item = GTK_ACTION_GET_CLASS (action)->create_menu_item (action);
-
- gtk_activatable_set_use_action_appearance (GTK_ACTIVATABLE (menu_item), TRUE);
- gtk_activatable_set_related_action (GTK_ACTIVATABLE (menu_item), action);
-
- return menu_item;
-}
-
-/**
- * gtk_action_create_tool_item:
- * @action: the action object
- *
- * Creates a toolbar item widget that proxies for the given action.
- *
- * Returns: (transfer none): a toolbar item connected to the action.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-GtkWidget *
-gtk_action_create_tool_item (GtkAction *action)
-{
- GtkWidget *button;
-
- g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
-
- button = GTK_ACTION_GET_CLASS (action)->create_tool_item (action);
-
- gtk_activatable_set_use_action_appearance (GTK_ACTIVATABLE (button), TRUE);
- gtk_activatable_set_related_action (GTK_ACTIVATABLE (button), action);
-
- return button;
-}
-
-void
-_gtk_action_add_to_proxy_list (GtkAction *action,
- GtkWidget *proxy)
-{
- g_return_if_fail (GTK_IS_ACTION (action));
- g_return_if_fail (GTK_IS_WIDGET (proxy));
-
- GTK_ACTION_GET_CLASS (action)->connect_proxy (action, proxy);
-}
-
-void
-_gtk_action_remove_from_proxy_list (GtkAction *action,
- GtkWidget *proxy)
-{
- g_return_if_fail (GTK_IS_ACTION (action));
- g_return_if_fail (GTK_IS_WIDGET (proxy));
-
- GTK_ACTION_GET_CLASS (action)->disconnect_proxy (action, proxy);
-}
-
-/**
- * gtk_action_get_proxies:
- * @action: the action object
- *
- * Returns the proxy widgets for an action.
- * See also gtk_activatable_get_related_action().
- *
- * Return value: (element-type GtkWidget) (transfer none): a #GSList of proxy widgets. The list is owned by GTK+
- * and must not be modified.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-GSList*
-gtk_action_get_proxies (GtkAction *action)
-{
- g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
-
- return action->private_data->proxies;
-}
-
-/**
- * gtk_action_get_name:
- * @action: the action object
- *
- * Returns the name of the action.
- *
- * Return value: the name of the action. The string belongs to GTK+ and should not
- * be freed.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-const gchar *
-gtk_action_get_name (GtkAction *action)
-{
- g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
-
- return action->private_data->name;
-}
-
-/**
- * gtk_action_is_sensitive:
- * @action: the action object
- *
- * Returns whether the action is effectively sensitive.
- *
- * Return value: %TRUE if the action and its associated action group
- * are both sensitive.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-gboolean
-gtk_action_is_sensitive (GtkAction *action)
-{
- GtkActionPrivate *priv;
- g_return_val_if_fail (GTK_IS_ACTION (action), FALSE);
-
- priv = action->private_data;
- return priv->sensitive &&
- (priv->action_group == NULL ||
- gtk_action_group_get_sensitive (priv->action_group));
-}
-
-/**
- * gtk_action_get_sensitive:
- * @action: the action object
- *
- * Returns whether the action itself is sensitive. Note that this doesn't
- * necessarily mean effective sensitivity. See gtk_action_is_sensitive()
- * for that.
- *
- * Return value: %TRUE if the action itself is sensitive.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-gboolean
-gtk_action_get_sensitive (GtkAction *action)
-{
- g_return_val_if_fail (GTK_IS_ACTION (action), FALSE);
-
- return action->private_data->sensitive;
-}
-
-/**
- * gtk_action_set_sensitive:
- * @action: the action object
- * @sensitive: %TRUE to make the action sensitive
- *
- * Sets the ::sensitive property of the action to @sensitive. Note that
- * this doesn't necessarily mean effective sensitivity. See
- * gtk_action_is_sensitive()
- * for that.
- *
- * Since: 2.6
- *
- * Deprecated: 3.10
- **/
-void
-gtk_action_set_sensitive (GtkAction *action,
- gboolean sensitive)
-{
- g_return_if_fail (GTK_IS_ACTION (action));
-
- sensitive = sensitive != FALSE;
-
- if (action->private_data->sensitive != sensitive)
- {
- action->private_data->sensitive = sensitive;
-
- g_object_notify (G_OBJECT (action), "sensitive");
- }
-}
-
-/**
- * gtk_action_is_visible:
- * @action: the action object
- *
- * Returns whether the action is effectively visible.
- *
- * Return value: %TRUE if the action and its associated action group
- * are both visible.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-gboolean
-gtk_action_is_visible (GtkAction *action)
-{
- GtkActionPrivate *priv;
- g_return_val_if_fail (GTK_IS_ACTION (action), FALSE);
-
- priv = action->private_data;
- return priv->visible &&
- (priv->action_group == NULL ||
- gtk_action_group_get_visible (priv->action_group));
-}
-
-/**
- * gtk_action_get_visible:
- * @action: the action object
- *
- * Returns whether the action itself is visible. Note that this doesn't
- * necessarily mean effective visibility. See gtk_action_is_sensitive()
- * for that.
- *
- * Return value: %TRUE if the action itself is visible.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-gboolean
-gtk_action_get_visible (GtkAction *action)
-{
- g_return_val_if_fail (GTK_IS_ACTION (action), FALSE);
-
- return action->private_data->visible;
-}
-
-/**
- * gtk_action_set_visible:
- * @action: the action object
- * @visible: %TRUE to make the action visible
- *
- * Sets the ::visible property of the action to @visible. Note that
- * this doesn't necessarily mean effective visibility. See
- * gtk_action_is_visible()
- * for that.
- *
- * Since: 2.6
- *
- * Deprecated: 3.10
- **/
-void
-gtk_action_set_visible (GtkAction *action,
- gboolean visible)
-{
- g_return_if_fail (GTK_IS_ACTION (action));
-
- visible = visible != FALSE;
-
- if (action->private_data->visible != visible)
- {
- action->private_data->visible = visible;
-
- g_object_notify (G_OBJECT (action), "visible");
- }
-}
-/**
- * gtk_action_set_is_important:
- * @action: the action object
- * @is_important: %TRUE to make the action important
- *
- * Sets whether the action is important, this attribute is used
- * primarily by toolbar items to decide whether to show a label
- * or not.
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-void
-gtk_action_set_is_important (GtkAction *action,
- gboolean is_important)
-{
- g_return_if_fail (GTK_IS_ACTION (action));
-
- is_important = is_important != FALSE;
-
- if (action->private_data->is_important != is_important)
- {
- action->private_data->is_important = is_important;
-
- g_object_notify (G_OBJECT (action), "is-important");
- }
-}
-
-/**
- * gtk_action_get_is_important:
- * @action: a #GtkAction
- *
- * Checks whether @action is important or not
- *
- * Returns: whether @action is important
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-gboolean
-gtk_action_get_is_important (GtkAction *action)
-{
- g_return_val_if_fail (GTK_IS_ACTION (action), FALSE);
-
- return action->private_data->is_important;
-}
-
-/**
- * gtk_action_set_always_show_image:
- * @action: a #GtkAction
- * @always_show: %TRUE if menuitem proxies should always show their image
- *
- * Sets whether @action<!-- -->'s menu item proxies will always show
- * their image, if available.
- *
- * Use this if the menu item would be useless or hard to use
- * without their image.
- *
- * Since: 2.20
- *
- * Deprecated: 3.10
- */
-void
-gtk_action_set_always_show_image (GtkAction *action,
- gboolean always_show)
-{
- GtkActionPrivate *priv;
-
- g_return_if_fail (GTK_IS_ACTION (action));
-
- priv = action->private_data;
-
- always_show = always_show != FALSE;
-
- if (priv->always_show_image != always_show)
- {
- priv->always_show_image = always_show;
-
- g_object_notify (G_OBJECT (action), "always-show-image");
- }
-}
-
-/**
- * gtk_action_get_always_show_image:
- * @action: a #GtkAction
- *
- * Returns whether @action<!-- -->'s menu item proxies will always
- * show their image, if available.
- *
- * Returns: %TRUE if the menu item proxies will always show their image
- *
- * Since: 2.20
- *
- * Deprecated: 3.10
- */
-gboolean
-gtk_action_get_always_show_image (GtkAction *action)
-{
- g_return_val_if_fail (GTK_IS_ACTION (action), FALSE);
-
- return action->private_data->always_show_image;
-}
-
-/**
- * gtk_action_set_label:
- * @action: a #GtkAction
- * @label: the label text to set
- *
- * Sets the label of @action.
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-void
-gtk_action_set_label (GtkAction *action,
- const gchar *label)
-{
- gchar *tmp;
-
- g_return_if_fail (GTK_IS_ACTION (action));
-
- tmp = action->private_data->label;
- action->private_data->label = g_strdup (label);
- g_free (tmp);
- action->private_data->label_set = (action->private_data->label != NULL);
- /* if label is unset, then use the label from the stock item */
- if (!action->private_data->label_set && action->private_data->stock_id)
- {
- GtkStockItem stock_item;
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-
- if (gtk_stock_lookup (action->private_data->stock_id, &stock_item))
- action->private_data->label = g_strdup (stock_item.label);
-
- G_GNUC_END_IGNORE_DEPRECATIONS;
- }
-
- g_object_notify (G_OBJECT (action), "label");
-
- /* if short_label is unset, set short_label=label */
- if (!action->private_data->short_label_set)
- {
- gtk_action_set_short_label (action, action->private_data->label);
- action->private_data->short_label_set = FALSE;
- }
-}
-
-/**
- * gtk_action_get_label:
- * @action: a #GtkAction
- *
- * Gets the label text of @action.
- *
- * Returns: the label text
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-const gchar *
-gtk_action_get_label (GtkAction *action)
-{
- g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
-
- return action->private_data->label;
-}
-
-/**
- * gtk_action_set_short_label:
- * @action: a #GtkAction
- * @short_label: the label text to set
- *
- * Sets a shorter label text on @action.
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-void
-gtk_action_set_short_label (GtkAction *action,
- const gchar *short_label)
-{
- gchar *tmp;
-
- g_return_if_fail (GTK_IS_ACTION (action));
-
- tmp = action->private_data->short_label;
- action->private_data->short_label = g_strdup (short_label);
- g_free (tmp);
- action->private_data->short_label_set = (action->private_data->short_label != NULL);
- /* if short_label is unset, then use the value of label */
- if (!action->private_data->short_label_set)
- action->private_data->short_label = g_strdup (action->private_data->label);
-
- g_object_notify (G_OBJECT (action), "short-label");
-}
-
-/**
- * gtk_action_get_short_label:
- * @action: a #GtkAction
- *
- * Gets the short label text of @action.
- *
- * Returns: the short label text.
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-const gchar *
-gtk_action_get_short_label (GtkAction *action)
-{
- g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
-
- return action->private_data->short_label;
-}
-
-/**
- * gtk_action_set_visible_horizontal:
- * @action: a #GtkAction
- * @visible_horizontal: whether the action is visible horizontally
- *
- * Sets whether @action is visible when horizontal
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-void
-gtk_action_set_visible_horizontal (GtkAction *action,
- gboolean visible_horizontal)
-{
- g_return_if_fail (GTK_IS_ACTION (action));
-
- g_return_if_fail (GTK_IS_ACTION (action));
-
- visible_horizontal = visible_horizontal != FALSE;
-
- if (action->private_data->visible_horizontal != visible_horizontal)
- {
- action->private_data->visible_horizontal = visible_horizontal;
-
- g_object_notify (G_OBJECT (action), "visible-horizontal");
- }
-}
-
-/**
- * gtk_action_get_visible_horizontal:
- * @action: a #GtkAction
- *
- * Checks whether @action is visible when horizontal
- *
- * Returns: whether @action is visible when horizontal
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-gboolean
-gtk_action_get_visible_horizontal (GtkAction *action)
-{
- g_return_val_if_fail (GTK_IS_ACTION (action), FALSE);
-
- return action->private_data->visible_horizontal;
-}
-
-/**
- * gtk_action_set_visible_vertical:
- * @action: a #GtkAction
- * @visible_vertical: whether the action is visible vertically
- *
- * Sets whether @action is visible when vertical
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-void
-gtk_action_set_visible_vertical (GtkAction *action,
- gboolean visible_vertical)
-{
- g_return_if_fail (GTK_IS_ACTION (action));
-
- g_return_if_fail (GTK_IS_ACTION (action));
-
- visible_vertical = visible_vertical != FALSE;
-
- if (action->private_data->visible_vertical != visible_vertical)
- {
- action->private_data->visible_vertical = visible_vertical;
-
- g_object_notify (G_OBJECT (action), "visible-vertical");
- }
-}
-
-/**
- * gtk_action_get_visible_vertical:
- * @action: a #GtkAction
- *
- * Checks whether @action is visible when horizontal
- *
- * Returns: whether @action is visible when horizontal
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-gboolean
-gtk_action_get_visible_vertical (GtkAction *action)
-{
- g_return_val_if_fail (GTK_IS_ACTION (action), FALSE);
-
- return action->private_data->visible_vertical;
-}
-
-/**
- * gtk_action_set_tooltip:
- * @action: a #GtkAction
- * @tooltip: the tooltip text
- *
- * Sets the tooltip text on @action
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-void
-gtk_action_set_tooltip (GtkAction *action,
- const gchar *tooltip)
-{
- gchar *tmp;
-
- g_return_if_fail (GTK_IS_ACTION (action));
-
- tmp = action->private_data->tooltip;
- action->private_data->tooltip = g_strdup (tooltip);
- g_free (tmp);
-
- g_object_notify (G_OBJECT (action), "tooltip");
-}
-
-/**
- * gtk_action_get_tooltip:
- * @action: a #GtkAction
- *
- * Gets the tooltip text of @action.
- *
- * Returns: the tooltip text
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-const gchar *
-gtk_action_get_tooltip (GtkAction *action)
-{
- g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
-
- return action->private_data->tooltip;
-}
-
-/**
- * gtk_action_set_stock_id:
- * @action: a #GtkAction
- * @stock_id: the stock id
- *
- * Sets the stock id on @action
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-void
-gtk_action_set_stock_id (GtkAction *action,
- const gchar *stock_id)
-{
- gchar *tmp;
-
- g_return_if_fail (GTK_IS_ACTION (action));
-
- g_return_if_fail (GTK_IS_ACTION (action));
-
- tmp = action->private_data->stock_id;
- action->private_data->stock_id = g_strdup (stock_id);
- g_free (tmp);
-
- g_object_notify (G_OBJECT (action), "stock-id");
-
- /* update label and short_label if appropriate */
- if (!action->private_data->label_set)
- {
- GtkStockItem stock_item;
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-
- if (action->private_data->stock_id &&
- gtk_stock_lookup (action->private_data->stock_id, &stock_item))
- gtk_action_set_label (action, stock_item.label);
- else
- gtk_action_set_label (action, NULL);
-
- G_GNUC_END_IGNORE_DEPRECATIONS;
-
- action->private_data->label_set = FALSE;
- }
-}
-
-/**
- * gtk_action_get_stock_id:
- * @action: a #GtkAction
- *
- * Gets the stock id of @action.
- *
- * Returns: the stock id
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-const gchar *
-gtk_action_get_stock_id (GtkAction *action)
-{
- g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
-
- return action->private_data->stock_id;
-}
-
-/**
- * gtk_action_set_icon_name:
- * @action: a #GtkAction
- * @icon_name: the icon name to set
- *
- * Sets the icon name on @action
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-void
-gtk_action_set_icon_name (GtkAction *action,
- const gchar *icon_name)
-{
- gchar *tmp;
-
- g_return_if_fail (GTK_IS_ACTION (action));
-
- tmp = action->private_data->icon_name;
- action->private_data->icon_name = g_strdup (icon_name);
- g_free (tmp);
-
- g_object_notify (G_OBJECT (action), "icon-name");
-}
-
-/**
- * gtk_action_get_icon_name:
- * @action: a #GtkAction
- *
- * Gets the icon name of @action.
- *
- * Returns: the icon name
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-const gchar *
-gtk_action_get_icon_name (GtkAction *action)
-{
- g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
-
- return action->private_data->icon_name;
-}
-
-/**
- * gtk_action_set_gicon:
- * @action: a #GtkAction
- * @icon: the #GIcon to set
- *
- * Sets the icon of @action.
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-void
-gtk_action_set_gicon (GtkAction *action,
- GIcon *icon)
-{
- g_return_if_fail (GTK_IS_ACTION (action));
-
- if (action->private_data->gicon)
- g_object_unref (action->private_data->gicon);
-
- action->private_data->gicon = icon;
-
- if (action->private_data->gicon)
- g_object_ref (action->private_data->gicon);
-
- g_object_notify (G_OBJECT (action), "gicon");
-}
-
-/**
- * gtk_action_get_gicon:
- * @action: a #GtkAction
- *
- * Gets the gicon of @action.
- *
- * Returns: (transfer none): The action's #GIcon if one is set.
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-GIcon *
-gtk_action_get_gicon (GtkAction *action)
-{
- g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
-
- return action->private_data->gicon;
-}
-
-static void
-closure_accel_activate (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data)
-{
- if (gtk_action_is_sensitive (GTK_ACTION (closure->data)))
- {
- _gtk_action_emit_activate (GTK_ACTION (closure->data));
-
- /* we handled the accelerator */
- g_value_set_boolean (return_value, TRUE);
- }
-}
-
-static void
-gtk_action_set_action_group (GtkAction *action,
- GtkActionGroup *action_group)
-{
- if (action->private_data->action_group == NULL)
- g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
- else
- g_return_if_fail (action_group == NULL);
-
- action->private_data->action_group = action_group;
-}
-
-/**
- * gtk_action_set_accel_path:
- * @action: the action object
- * @accel_path: the accelerator path
- *
- * Sets the accel path for this action. All proxy widgets associated
- * with the action will have this accel path, so that their
- * accelerators are consistent.
- *
- * Note that @accel_path string will be stored in a #GQuark. Therefore, if you
- * pass a static string, you can save some memory by interning it first with
- * g_intern_static_string().
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-void
-gtk_action_set_accel_path (GtkAction *action,
- const gchar *accel_path)
-{
- g_return_if_fail (GTK_IS_ACTION (action));
-
- action->private_data->accel_quark = g_quark_from_string (accel_path);
-}
-
-/**
- * gtk_action_get_accel_path:
- * @action: the action object
- *
- * Returns the accel path for this action.
- *
- * Since: 2.6
- *
- * Returns: the accel path for this action, or %NULL
- * if none is set. The returned string is owned by GTK+
- * and must not be freed or modified.
- *
- * Deprecated: 3.10
- */
-const gchar *
-gtk_action_get_accel_path (GtkAction *action)
-{
- g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
-
- if (action->private_data->accel_quark)
- return g_quark_to_string (action->private_data->accel_quark);
- else
- return NULL;
-}
-
-/**
- * gtk_action_get_accel_closure:
- * @action: the action object
- *
- * Returns the accel closure for this action.
- *
- * Since: 2.8
- *
- * Returns: (transfer none): the accel closure for this action. The
- * returned closure is owned by GTK+ and must not be unreffed
- * or modified.
- *
- * Deprecated: 3.10
- */
-GClosure *
-gtk_action_get_accel_closure (GtkAction *action)
-{
- g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
-
- return action->private_data->accel_closure;
-}
-
-
-/**
- * gtk_action_set_accel_group:
- * @action: the action object
- * @accel_group: (allow-none): a #GtkAccelGroup or %NULL
- *
- * Sets the #GtkAccelGroup in which the accelerator for this action
- * will be installed.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-void
-gtk_action_set_accel_group (GtkAction *action,
- GtkAccelGroup *accel_group)
-{
- g_return_if_fail (GTK_IS_ACTION (action));
- g_return_if_fail (accel_group == NULL || GTK_IS_ACCEL_GROUP (accel_group));
-
- if (accel_group)
- g_object_ref (accel_group);
- if (action->private_data->accel_group)
- g_object_unref (action->private_data->accel_group);
-
- action->private_data->accel_group = accel_group;
-}
-
-/**
- * gtk_action_connect_accelerator:
- * @action: a #GtkAction
- *
- * Installs the accelerator for @action if @action has an
- * accel path and group. See gtk_action_set_accel_path() and
- * gtk_action_set_accel_group()
- *
- * Since multiple proxies may independently trigger the installation
- * of the accelerator, the @action counts the number of times this
- * function has been called and doesn't remove the accelerator until
- * gtk_action_disconnect_accelerator() has been called as many times.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-void
-gtk_action_connect_accelerator (GtkAction *action)
-{
- g_return_if_fail (GTK_IS_ACTION (action));
-
- if (!action->private_data->accel_quark ||
- !action->private_data->accel_group)
- return;
-
- if (action->private_data->accel_count == 0)
- {
- const gchar *accel_path =
- g_quark_to_string (action->private_data->accel_quark);
-
- gtk_accel_group_connect_by_path (action->private_data->accel_group,
- accel_path,
- action->private_data->accel_closure);
- }
-
- action->private_data->accel_count++;
-}
-
-/**
- * gtk_action_disconnect_accelerator:
- * @action: a #GtkAction
- *
- * Undoes the effect of one call to gtk_action_connect_accelerator().
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-void
-gtk_action_disconnect_accelerator (GtkAction *action)
-{
- g_return_if_fail (GTK_IS_ACTION (action));
-
- if (!action->private_data->accel_quark ||
- !action->private_data->accel_group)
- return;
-
- action->private_data->accel_count--;
-
- if (action->private_data->accel_count == 0)
- gtk_accel_group_disconnect (action->private_data->accel_group,
- action->private_data->accel_closure);
-}
-
-/**
- * gtk_action_create_menu:
- * @action: a #GtkAction
- *
- * If @action provides a #GtkMenu widget as a submenu for the menu
- * item or the toolbar item it creates, this function returns an
- * instance of that menu.
- *
- * Return value: (transfer none): the menu item provided by the
- * action, or %NULL.
- *
- * Since: 2.12
- *
- * Deprecated: 3.10
- */
-GtkWidget *
-gtk_action_create_menu (GtkAction *action)
-{
- g_return_val_if_fail (GTK_IS_ACTION (action), NULL);
-
- if (GTK_ACTION_GET_CLASS (action)->create_menu)
- return GTK_ACTION_GET_CLASS (action)->create_menu (action);
-
- return NULL;
-}
+++ /dev/null
-/*
- * GTK - The GIMP Toolkit
- * Copyright (C) 1998, 1999 Red Hat, Inc.
- * All rights reserved.
- *
- * This Library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This Library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Author: James Henstridge <james@daa.com.au>
- *
- * Modified by the GTK+ Team and others 2003. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#ifndef __GTK_ACTION_H__
-#define __GTK_ACTION_H__
-
-#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
-#error "Only <gtk/gtk.h> can be included directly."
-#endif
-
-#include <gtk/gtkwidget.h>
-
-G_BEGIN_DECLS
-
-#define GTK_TYPE_ACTION (gtk_action_get_type ())
-#define GTK_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ACTION, GtkAction))
-#define GTK_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ACTION, GtkActionClass))
-#define GTK_IS_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ACTION))
-#define GTK_IS_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ACTION))
-#define GTK_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_ACTION, GtkActionClass))
-
-typedef struct _GtkAction GtkAction;
-typedef struct _GtkActionClass GtkActionClass;
-typedef struct _GtkActionPrivate GtkActionPrivate;
-
-struct _GtkAction
-{
- GObject object;
-
- /*< private >*/
- GtkActionPrivate *private_data;
-};
-
-struct _GtkActionClass
-{
- GObjectClass parent_class;
-
- /* activation signal */
- void (* activate) (GtkAction *action);
-
- GType menu_item_type;
- GType toolbar_item_type;
-
- /* widget creation routines (not signals) */
- GtkWidget *(* create_menu_item) (GtkAction *action);
- GtkWidget *(* create_tool_item) (GtkAction *action);
- void (* connect_proxy) (GtkAction *action,
- GtkWidget *proxy);
- void (* disconnect_proxy) (GtkAction *action,
- GtkWidget *proxy);
-
- GtkWidget *(* create_menu) (GtkAction *action);
-
- /* Padding for future expansion */
- void (*_gtk_reserved1) (void);
- void (*_gtk_reserved2) (void);
- void (*_gtk_reserved3) (void);
- void (*_gtk_reserved4) (void);
-};
-
-GDK_DEPRECATED_IN_3_10
-GType gtk_action_get_type (void) G_GNUC_CONST;
-GDK_DEPRECATED_IN_3_10
-GtkAction *gtk_action_new (const gchar *name,
- const gchar *label,
- const gchar *tooltip,
- const gchar *stock_id);
-GDK_DEPRECATED_IN_3_10
-const gchar* gtk_action_get_name (GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-gboolean gtk_action_is_sensitive (GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-gboolean gtk_action_get_sensitive (GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_set_sensitive (GtkAction *action,
- gboolean sensitive);
-GDK_DEPRECATED_IN_3_10
-gboolean gtk_action_is_visible (GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-gboolean gtk_action_get_visible (GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_set_visible (GtkAction *action,
- gboolean visible);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_activate (GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-GtkWidget * gtk_action_create_icon (GtkAction *action,
- GtkIconSize icon_size);
-GDK_DEPRECATED_IN_3_10
-GtkWidget * gtk_action_create_menu_item (GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-GtkWidget * gtk_action_create_tool_item (GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-GtkWidget * gtk_action_create_menu (GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-GSList * gtk_action_get_proxies (GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_connect_accelerator (GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_disconnect_accelerator (GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-const gchar *gtk_action_get_accel_path (GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-GClosure *gtk_action_get_accel_closure (GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_block_activate (GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_unblock_activate (GtkAction *action);
-
-void _gtk_action_add_to_proxy_list (GtkAction *action,
- GtkWidget *proxy);
-void _gtk_action_remove_from_proxy_list(GtkAction *action,
- GtkWidget *proxy);
-
-/* protected ... for use by child actions */
-void _gtk_action_emit_activate (GtkAction *action);
-
-/* protected ... for use by action groups */
-GDK_DEPRECATED_IN_3_10
-void gtk_action_set_accel_path (GtkAction *action,
- const gchar *accel_path);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_set_accel_group (GtkAction *action,
- GtkAccelGroup *accel_group);
-void _gtk_action_sync_menu_visible (GtkAction *action,
- GtkWidget *proxy,
- gboolean empty);
-
-GDK_DEPRECATED_IN_3_10
-void gtk_action_set_label (GtkAction *action,
- const gchar *label);
-GDK_DEPRECATED_IN_3_10
-const gchar * gtk_action_get_label (GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_set_short_label (GtkAction *action,
- const gchar *short_label);
-GDK_DEPRECATED_IN_3_10
-const gchar * gtk_action_get_short_label (GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_set_tooltip (GtkAction *action,
- const gchar *tooltip);
-GDK_DEPRECATED_IN_3_10
-const gchar * gtk_action_get_tooltip (GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_set_stock_id (GtkAction *action,
- const gchar *stock_id);
-GDK_DEPRECATED_IN_3_10
-const gchar * gtk_action_get_stock_id (GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_set_gicon (GtkAction *action,
- GIcon *icon);
-GDK_DEPRECATED_IN_3_10
-GIcon *gtk_action_get_gicon (GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_set_icon_name (GtkAction *action,
- const gchar *icon_name);
-GDK_DEPRECATED_IN_3_10
-const gchar * gtk_action_get_icon_name (GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_set_visible_horizontal (GtkAction *action,
- gboolean visible_horizontal);
-GDK_DEPRECATED_IN_3_10
-gboolean gtk_action_get_visible_horizontal (GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_set_visible_vertical (GtkAction *action,
- gboolean visible_vertical);
-GDK_DEPRECATED_IN_3_10
-gboolean gtk_action_get_visible_vertical (GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_set_is_important (GtkAction *action,
- gboolean is_important);
-GDK_DEPRECATED_IN_3_10
-gboolean gtk_action_get_is_important (GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_set_always_show_image (GtkAction *action,
- gboolean always_show);
-GDK_DEPRECATED_IN_3_10
-gboolean gtk_action_get_always_show_image (GtkAction *action);
-
-
-G_END_DECLS
-
-#endif /* __GTK_ACTION_H__ */
+++ /dev/null
-/*
- * GTK - The GIMP Toolkit
- * Copyright (C) 1998, 1999 Red Hat, Inc.
- * All rights reserved.
- *
- * This Library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This Library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Author: James Henstridge <james@daa.com.au>
- *
- * Modified by the GTK+ Team and others 2003. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-/**
- * SECTION:gtkactiongroup
- * @Short_description: A group of actions
- * @Title: GtkActionGroup
- *
- * Actions are organised into groups. An action group is essentially a
- * map from names to #GtkAction objects.
- *
- * All actions that would make sense to use in a particular context
- * should be in a single group. Multiple action groups may be used for a
- * particular user interface. In fact, it is expected that most nontrivial
- * applications will make use of multiple groups. For example, in an
- * application that can edit multiple documents, one group holding global
- * actions (e.g. quit, about, new), and one group per document holding
- * actions that act on that document (eg. save, cut/copy/paste, etc). Each
- * window's menus would be constructed from a combination of two action
- * groups.
- * </para>
- * <para id="Action-Accel">
- * Accelerators are handled by the GTK+ accelerator map. All actions are
- * assigned an accelerator path (which normally has the form
- * <literal><Actions>/group-name/action-name</literal>)
- * and a shortcut is associated with this accelerator path. All menuitems
- * and toolitems take on this accelerator path. The GTK+ accelerator map
- * code makes sure that the correct shortcut is displayed next to the menu
- * item.
- *
- * <refsect2 id="GtkActionGroup-BUILDER-UI">
- * <title>GtkActionGroup as GtkBuildable</title>
- * <para>
- * The #GtkActionGroup implementation of the #GtkBuildable interface accepts
- * #GtkAction objects as <child> elements in UI definitions.
- *
- * Note that it is probably more common to define actions and action groups
- * in the code, since they are directly related to what the code can do.
- *
- * The GtkActionGroup implementation of the GtkBuildable interface supports
- * a custom <accelerator> element, which has attributes named key and
- * modifiers and allows to specify accelerators. This is similar to the
- * <accelerator> element of #GtkWidget, the main difference is that
- * it doesn't allow you to specify a signal.
- * </para>
- * <example>
- * <title>A #GtkDialog UI definition fragment.</title>
- * <programlisting><![CDATA[
- * <object class="GtkActionGroup" id="actiongroup">
- * <child>
- * <object class="GtkAction" id="About">
- * <property name="name">About</property>
- * <property name="stock_id">gtk-about</property>
- * <signal handler="about_activate" name="activate"/>
- * </object>
- * <accelerator key="F1" modifiers="GDK_CONTROL_MASK | GDK_SHIFT_MASK"/>
- * </child>
- * </object>
- * ]]></programlisting>
- * </example>
- * </refsect2>
- */
-
-#include "config.h"
-#include <string.h>
-
-#define GDK_DISABLE_DEPRECATION_WARNINGS
-
-#include "gtkactiongroup.h"
-#include "gtkbuildable.h"
-#include "gtkiconfactory.h"
-#include "gtkicontheme.h"
-#include "gtkstock.h"
-#include "gtktoggleaction.h"
-#include "gtkradioaction.h"
-#include "gtkaccelmap.h"
-#include "gtkmarshalers.h"
-#include "gtkbuilderprivate.h"
-#include "gtkprivate.h"
-#include "gtkintl.h"
-
-
-struct _GtkActionGroupPrivate
-{
- gchar *name;
- gboolean sensitive;
- gboolean visible;
- GHashTable *actions;
- GtkAccelGroup *accel_group;
-
- GtkTranslateFunc translate_func;
- gpointer translate_data;
- GDestroyNotify translate_notify;
-};
-
-enum
-{
- CONNECT_PROXY,
- DISCONNECT_PROXY,
- PRE_ACTIVATE,
- POST_ACTIVATE,
- LAST_SIGNAL
-};
-
-enum
-{
- PROP_0,
- PROP_NAME,
- PROP_SENSITIVE,
- PROP_VISIBLE,
- PROP_ACCEL_GROUP
-};
-
-static void gtk_action_group_init (GtkActionGroup *self);
-static void gtk_action_group_class_init (GtkActionGroupClass *class);
-static void gtk_action_group_finalize (GObject *object);
-static void gtk_action_group_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gtk_action_group_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static GtkAction *gtk_action_group_real_get_action (GtkActionGroup *self,
- const gchar *name);
-
-/* GtkBuildable */
-static void gtk_action_group_buildable_init (GtkBuildableIface *iface);
-static void gtk_action_group_buildable_add_child (GtkBuildable *buildable,
- GtkBuilder *builder,
- GObject *child,
- const gchar *type);
-static void gtk_action_group_buildable_set_name (GtkBuildable *buildable,
- const gchar *name);
-static const gchar* gtk_action_group_buildable_get_name (GtkBuildable *buildable);
-static gboolean gtk_action_group_buildable_custom_tag_start (GtkBuildable *buildable,
- GtkBuilder *builder,
- GObject *child,
- const gchar *tagname,
- GMarkupParser *parser,
- gpointer *data);
-static void gtk_action_group_buildable_custom_tag_end (GtkBuildable *buildable,
- GtkBuilder *builder,
- GObject *child,
- const gchar *tagname,
- gpointer *user_data);
-
-static guint action_group_signals[LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE_WITH_CODE (GtkActionGroup, gtk_action_group, G_TYPE_OBJECT,
- G_ADD_PRIVATE (GtkActionGroup)
- G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
- gtk_action_group_buildable_init))
-
-static void
-gtk_action_group_class_init (GtkActionGroupClass *klass)
-{
- GObjectClass *gobject_class;
-
- gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->finalize = gtk_action_group_finalize;
- gobject_class->set_property = gtk_action_group_set_property;
- gobject_class->get_property = gtk_action_group_get_property;
- klass->get_action = gtk_action_group_real_get_action;
-
- /**
- * GtkActionGroup:name:
- *
- * A name for the action.
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_NAME,
- g_param_spec_string ("name",
- P_("Name"),
- P_("A name for the action group."),
- NULL,
- GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- /**
- * GtkActionGroup:sensitive:
- *
- * Whether the action group is enabled.
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_SENSITIVE,
- g_param_spec_boolean ("sensitive",
- P_("Sensitive"),
- P_("Whether the action group is enabled."),
- TRUE,
- GTK_PARAM_READWRITE));
- /**
- * GtkActionGroup:visible:
- *
- * Whether the action group is visible.
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_VISIBLE,
- g_param_spec_boolean ("visible",
- P_("Visible"),
- P_("Whether the action group is visible."),
- TRUE,
- GTK_PARAM_READWRITE));
- /**
- * GtkActionGroup:accel-group:
- *
- * The accelerator group the actions of this group should use.
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_ACCEL_GROUP,
- g_param_spec_object ("accel-group",
- P_("Accelerator Group"),
- P_("The accelerator group the actions of this group should use."),
- GTK_TYPE_ACCEL_GROUP,
- GTK_PARAM_READWRITE));
-
- /**
- * GtkActionGroup::connect-proxy:
- * @action_group: the group
- * @action: the action
- * @proxy: the proxy
- *
- * The ::connect-proxy signal is emitted after connecting a proxy to
- * an action in the group. Note that the proxy may have been connected
- * to a different action before.
- *
- * This is intended for simple customizations for which a custom action
- * class would be too clumsy, e.g. showing tooltips for menuitems in the
- * statusbar.
- *
- * #GtkUIManager proxies the signal and provides global notification
- * just before any action is connected to a proxy, which is probably more
- * convenient to use.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
- action_group_signals[CONNECT_PROXY] =
- g_signal_new (I_("connect-proxy"),
- G_OBJECT_CLASS_TYPE (klass),
- 0, 0, NULL, NULL,
- _gtk_marshal_VOID__OBJECT_OBJECT,
- G_TYPE_NONE, 2,
- GTK_TYPE_ACTION, GTK_TYPE_WIDGET);
-
- /**
- * GtkActionGroup::disconnect-proxy:
- * @action_group: the group
- * @action: the action
- * @proxy: the proxy
- *
- * The ::disconnect-proxy signal is emitted after disconnecting a proxy
- * from an action in the group.
- *
- * #GtkUIManager proxies the signal and provides global notification
- * just before any action is connected to a proxy, which is probably more
- * convenient to use.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
- action_group_signals[DISCONNECT_PROXY] =
- g_signal_new (I_("disconnect-proxy"),
- G_OBJECT_CLASS_TYPE (klass),
- 0, 0, NULL, NULL,
- _gtk_marshal_VOID__OBJECT_OBJECT,
- G_TYPE_NONE, 2,
- GTK_TYPE_ACTION, GTK_TYPE_WIDGET);
-
- /**
- * GtkActionGroup::pre-activate:
- * @action_group: the group
- * @action: the action
- *
- * The ::pre-activate signal is emitted just before the @action in the
- * @action_group is activated
- *
- * This is intended for #GtkUIManager to proxy the signal and provide global
- * notification just before any action is activated.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
- action_group_signals[PRE_ACTIVATE] =
- g_signal_new (I_("pre-activate"),
- G_OBJECT_CLASS_TYPE (klass),
- 0, 0, NULL, NULL,
- _gtk_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- GTK_TYPE_ACTION);
-
- /**
- * GtkActionGroup::post-activate:
- * @action_group: the group
- * @action: the action
- *
- * The ::post-activate signal is emitted just after the @action in the
- * @action_group is activated
- *
- * This is intended for #GtkUIManager to proxy the signal and provide global
- * notification just after any action is activated.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
- action_group_signals[POST_ACTIVATE] =
- g_signal_new (I_("post-activate"),
- G_OBJECT_CLASS_TYPE (klass),
- 0, 0, NULL, NULL,
- _gtk_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- GTK_TYPE_ACTION);
-}
-
-
-static void
-remove_action (GtkAction *action)
-{
- g_object_set (action, I_("action-group"), NULL, NULL);
- g_object_unref (action);
-}
-
-static void
-gtk_action_group_init (GtkActionGroup *action_group)
-{
- action_group->priv = gtk_action_group_get_instance_private (action_group);
- action_group->priv->name = NULL;
- action_group->priv->sensitive = TRUE;
- action_group->priv->visible = TRUE;
- action_group->priv->actions = g_hash_table_new_full (g_str_hash, g_str_equal,
- NULL,
- (GDestroyNotify) remove_action);
- action_group->priv->translate_func = NULL;
- action_group->priv->translate_data = NULL;
- action_group->priv->translate_notify = NULL;
-}
-
-static void
-gtk_action_group_buildable_init (GtkBuildableIface *iface)
-{
- iface->add_child = gtk_action_group_buildable_add_child;
- iface->set_name = gtk_action_group_buildable_set_name;
- iface->get_name = gtk_action_group_buildable_get_name;
- iface->custom_tag_start = gtk_action_group_buildable_custom_tag_start;
- iface->custom_tag_end = gtk_action_group_buildable_custom_tag_end;
-}
-
-static void
-gtk_action_group_buildable_add_child (GtkBuildable *buildable,
- GtkBuilder *builder,
- GObject *child,
- const gchar *type)
-{
- gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (buildable),
- GTK_ACTION (child), NULL);
-}
-
-static void
-gtk_action_group_buildable_set_name (GtkBuildable *buildable,
- const gchar *name)
-{
- GtkActionGroup *self = GTK_ACTION_GROUP (buildable);
- GtkActionGroupPrivate *private = self->priv;
-
- private->name = g_strdup (name);
-}
-
-static const gchar *
-gtk_action_group_buildable_get_name (GtkBuildable *buildable)
-{
- GtkActionGroup *self = GTK_ACTION_GROUP (buildable);
- GtkActionGroupPrivate *private = self->priv;
-
- return private->name;
-}
-
-typedef struct {
- GObject *child;
- guint key;
- GdkModifierType modifiers;
-} AcceleratorParserData;
-
-static void
-accelerator_start_element (GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **names,
- const gchar **values,
- gpointer user_data,
- GError **error)
-{
- gint i;
- guint key = 0;
- GdkModifierType modifiers = 0;
- AcceleratorParserData *parser_data = (AcceleratorParserData*)user_data;
-
- if (strcmp (element_name, "accelerator") != 0)
- g_warning ("Unknown <accelerator> tag: %s", element_name);
-
- for (i = 0; names[i]; i++)
- {
- if (strcmp (names[i], "key") == 0)
- key = gdk_keyval_from_name (values[i]);
- else if (strcmp (names[i], "modifiers") == 0)
- {
- if (!_gtk_builder_flags_from_string (GDK_TYPE_MODIFIER_TYPE,
- values[i],
- &modifiers,
- error))
- return;
- }
- }
-
- if (key == 0)
- {
- g_warning ("<accelerator> requires a key attribute");
- return;
- }
- parser_data->key = key;
- parser_data->modifiers = modifiers;
-}
-
-static const GMarkupParser accelerator_parser =
- {
- accelerator_start_element
- };
-
-static gboolean
-gtk_action_group_buildable_custom_tag_start (GtkBuildable *buildable,
- GtkBuilder *builder,
- GObject *child,
- const gchar *tagname,
- GMarkupParser *parser,
- gpointer *user_data)
-{
- AcceleratorParserData *parser_data;
-
- if (child && strcmp (tagname, "accelerator") == 0)
- {
- parser_data = g_slice_new0 (AcceleratorParserData);
- parser_data->child = child;
- *user_data = parser_data;
- *parser = accelerator_parser;
-
- return TRUE;
- }
- return FALSE;
-}
-
-static void
-gtk_action_group_buildable_custom_tag_end (GtkBuildable *buildable,
- GtkBuilder *builder,
- GObject *child,
- const gchar *tagname,
- gpointer *user_data)
-{
- AcceleratorParserData *data;
-
- if (strcmp (tagname, "accelerator") == 0)
- {
- GtkActionGroup *action_group;
- GtkActionGroupPrivate *private;
- GtkAction *action;
- gchar *accel_path;
-
- data = (AcceleratorParserData*)user_data;
- action_group = GTK_ACTION_GROUP (buildable);
- private = action_group->priv;
- action = GTK_ACTION (child);
-
- accel_path = g_strconcat ("<Actions>/",
- private->name, "/",
- gtk_action_get_name (action), NULL);
-
- if (gtk_accel_map_lookup_entry (accel_path, NULL))
- gtk_accel_map_change_entry (accel_path, data->key, data->modifiers, TRUE);
- else
- gtk_accel_map_add_entry (accel_path, data->key, data->modifiers);
-
- gtk_action_set_accel_path (action, accel_path);
-
- g_free (accel_path);
- g_slice_free (AcceleratorParserData, data);
- }
-}
-
-/**
- * gtk_action_group_new:
- * @name: the name of the action group.
- *
- * Creates a new #GtkActionGroup object. The name of the action group
- * is used when associating <link linkend="Action-Accel">keybindings</link>
- * with the actions.
- *
- * Returns: the new #GtkActionGroup
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-GtkActionGroup *
-gtk_action_group_new (const gchar *name)
-{
- GtkActionGroup *self;
- GtkActionGroupPrivate *private;
-
- self = g_object_new (GTK_TYPE_ACTION_GROUP, NULL);
- private = self->priv;
- private->name = g_strdup (name);
-
- return self;
-}
-
-static void
-gtk_action_group_finalize (GObject *object)
-{
- GtkActionGroup *self = GTK_ACTION_GROUP (object);
-
- g_free (self->priv->name);
-
- g_hash_table_destroy (self->priv->actions);
-
- g_clear_object (&self->priv->accel_group);
-
- if (self->priv->translate_notify != NULL)
- self->priv->translate_notify (self->priv->translate_data);
-
- G_OBJECT_CLASS (gtk_action_group_parent_class)->finalize (object);
-}
-
-static void
-gtk_action_group_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GtkActionGroup *self;
- GtkActionGroupPrivate *private;
- gchar *tmp;
-
- self = GTK_ACTION_GROUP (object);
- private = self->priv;
-
- switch (prop_id)
- {
- case PROP_NAME:
- tmp = private->name;
- private->name = g_value_dup_string (value);
- g_free (tmp);
- break;
- case PROP_SENSITIVE:
- gtk_action_group_set_sensitive (self, g_value_get_boolean (value));
- break;
- case PROP_VISIBLE:
- gtk_action_group_set_visible (self, g_value_get_boolean (value));
- break;
- case PROP_ACCEL_GROUP:
- gtk_action_group_set_accel_group (self, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gtk_action_group_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GtkActionGroup *self;
- GtkActionGroupPrivate *private;
-
- self = GTK_ACTION_GROUP (object);
- private = self->priv;
-
- switch (prop_id)
- {
- case PROP_NAME:
- g_value_set_string (value, private->name);
- break;
- case PROP_SENSITIVE:
- g_value_set_boolean (value, private->sensitive);
- break;
- case PROP_VISIBLE:
- g_value_set_boolean (value, private->visible);
- break;
- case PROP_ACCEL_GROUP:
- g_value_set_object (value, private->accel_group);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static GtkAction *
-gtk_action_group_real_get_action (GtkActionGroup *self,
- const gchar *action_name)
-{
- GtkActionGroupPrivate *private;
-
- private = self->priv;
-
- return g_hash_table_lookup (private->actions, action_name);
-}
-
-/**
- * gtk_action_group_get_name:
- * @action_group: the action group
- *
- * Gets the name of the action group.
- *
- * Returns: the name of the action group.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-const gchar *
-gtk_action_group_get_name (GtkActionGroup *action_group)
-{
- GtkActionGroupPrivate *private;
-
- g_return_val_if_fail (GTK_IS_ACTION_GROUP (action_group), NULL);
-
- private = action_group->priv;
-
- return private->name;
-}
-
-/**
- * gtk_action_group_get_sensitive:
- * @action_group: the action group
- *
- * Returns %TRUE if the group is sensitive. The constituent actions
- * can only be logically sensitive (see gtk_action_is_sensitive()) if
- * they are sensitive (see gtk_action_get_sensitive()) and their group
- * is sensitive.
- *
- * Return value: %TRUE if the group is sensitive.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-gboolean
-gtk_action_group_get_sensitive (GtkActionGroup *action_group)
-{
- GtkActionGroupPrivate *private;
-
- g_return_val_if_fail (GTK_IS_ACTION_GROUP (action_group), FALSE);
-
- private = action_group->priv;
-
- return private->sensitive;
-}
-
-static void
-cb_set_action_sensitivity (const gchar *name,
- GtkAction *action)
-{
- /* Minor optimization, the action_groups state only affects actions
- * that are themselves sensitive */
- g_object_notify (G_OBJECT (action), "sensitive");
-
-}
-
-/**
- * gtk_action_group_set_sensitive:
- * @action_group: the action group
- * @sensitive: new sensitivity
- *
- * Changes the sensitivity of @action_group
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-void
-gtk_action_group_set_sensitive (GtkActionGroup *action_group,
- gboolean sensitive)
-{
- GtkActionGroupPrivate *private;
-
- g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
-
- private = action_group->priv;
- sensitive = sensitive != FALSE;
-
- if (private->sensitive != sensitive)
- {
- private->sensitive = sensitive;
- g_hash_table_foreach (private->actions,
- (GHFunc) cb_set_action_sensitivity, NULL);
-
- g_object_notify (G_OBJECT (action_group), "sensitive");
- }
-}
-
-/**
- * gtk_action_group_get_visible:
- * @action_group: the action group
- *
- * Returns %TRUE if the group is visible. The constituent actions
- * can only be logically visible (see gtk_action_is_visible()) if
- * they are visible (see gtk_action_get_visible()) and their group
- * is visible.
- *
- * Return value: %TRUE if the group is visible.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-gboolean
-gtk_action_group_get_visible (GtkActionGroup *action_group)
-{
- GtkActionGroupPrivate *private;
-
- g_return_val_if_fail (GTK_IS_ACTION_GROUP (action_group), FALSE);
-
- private = action_group->priv;
-
- return private->visible;
-}
-
-/**
- * gtk_action_group_get_accel_group:
- * @action_group: a #GtkActionGroup
- *
- * Gets the accelerator group.
- *
- * Returns: (transfer none): the accelerator group associated with this action
- * group or %NULL if there is none.
- *
- * Since: 3.6
- *
- * Deprecated: 3.10
- */
-GtkAccelGroup *
-gtk_action_group_get_accel_group (GtkActionGroup *action_group)
-{
- g_return_val_if_fail (GTK_IS_ACTION_GROUP (action_group), FALSE);
-
- return action_group->priv->accel_group;
-}
-
-static void
-cb_set_action_visiblity (const gchar *name,
- GtkAction *action)
-{
- /* Minor optimization, the action_groups state only affects actions
- * that are themselves visible */
- g_object_notify (G_OBJECT (action), "visible");
-}
-
-/**
- * gtk_action_group_set_visible:
- * @action_group: the action group
- * @visible: new visiblity
- *
- * Changes the visible of @action_group.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-void
-gtk_action_group_set_visible (GtkActionGroup *action_group,
- gboolean visible)
-{
- GtkActionGroupPrivate *private;
-
- g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
-
- private = action_group->priv;
- visible = visible != FALSE;
-
- if (private->visible != visible)
- {
- private->visible = visible;
- g_hash_table_foreach (private->actions,
- (GHFunc) cb_set_action_visiblity, NULL);
-
- g_object_notify (G_OBJECT (action_group), "visible");
- }
-}
-
-static void
-gtk_action_group_accel_group_foreach (gpointer key, gpointer val, gpointer data)
-{
- gtk_action_set_accel_group (val, data);
-}
-
-/**
- * gtk_action_group_set_accel_group:
- * @action_group: a #GtkActionGroup
- * @accel_group: (allow-none): a #GtkAccelGroup to set or %NULL
- *
- * Sets the accelerator group to be used by every action in this group.
- *
- * Since: 3.6
- *
- * Deprecated: 3.10
- */
-void
-gtk_action_group_set_accel_group (GtkActionGroup *action_group,
- GtkAccelGroup *accel_group)
-{
- GtkActionGroupPrivate *private;
-
- g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
-
- private = action_group->priv;
-
- if (private->accel_group == accel_group)
- return;
-
- g_clear_object (&private->accel_group);
-
- if (accel_group)
- private->accel_group = g_object_ref (accel_group);
-
- /* Set the new accel group on every action */
- g_hash_table_foreach (private->actions,
- gtk_action_group_accel_group_foreach,
- accel_group);
-
- g_object_notify (G_OBJECT (action_group), "accel-group");
-}
-
-/**
- * gtk_action_group_get_action:
- * @action_group: the action group
- * @action_name: the name of the action
- *
- * Looks up an action in the action group by name.
- *
- * Returns: (transfer none): the action, or %NULL if no action by that name exists
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-GtkAction *
-gtk_action_group_get_action (GtkActionGroup *action_group,
- const gchar *action_name)
-{
- g_return_val_if_fail (GTK_IS_ACTION_GROUP (action_group), NULL);
- g_return_val_if_fail (GTK_ACTION_GROUP_GET_CLASS (action_group)->get_action != NULL, NULL);
-
- return GTK_ACTION_GROUP_GET_CLASS (action_group)->get_action (action_group,
- action_name);
-}
-
-static gboolean
-check_unique_action (GtkActionGroup *action_group,
- const gchar *action_name)
-{
- if (gtk_action_group_get_action (action_group, action_name) != NULL)
- {
- GtkActionGroupPrivate *private;
-
- private = action_group->priv;
-
- g_warning ("Refusing to add non-unique action '%s' to action group '%s'",
- action_name,
- private->name);
- return FALSE;
- }
-
- return TRUE;
-}
-
-/**
- * gtk_action_group_add_action:
- * @action_group: the action group
- * @action: an action
- *
- * Adds an action object to the action group. Note that this function
- * does not set up the accel path of the action, which can lead to problems
- * if a user tries to modify the accelerator of a menuitem associated with
- * the action. Therefore you must either set the accel path yourself with
- * gtk_action_set_accel_path(), or use
- * <literal>gtk_action_group_add_action_with_accel (..., NULL)</literal>.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-void
-gtk_action_group_add_action (GtkActionGroup *action_group,
- GtkAction *action)
-{
- GtkActionGroupPrivate *private;
- const gchar *name;
-
- g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
- g_return_if_fail (GTK_IS_ACTION (action));
-
- name = gtk_action_get_name (action);
- g_return_if_fail (name != NULL);
-
- if (!check_unique_action (action_group, name))
- return;
-
- private = action_group->priv;
-
- g_hash_table_insert (private->actions,
- (gpointer) name,
- g_object_ref (action));
- g_object_set (action, I_("action-group"), action_group, NULL);
-
- if (private->accel_group)
- gtk_action_set_accel_group (action, private->accel_group);
-}
-
-/**
- * gtk_action_group_add_action_with_accel:
- * @action_group: the action group
- * @action: the action to add
- * @accelerator: (allow-none): the accelerator for the action, in
- * the format understood by gtk_accelerator_parse(), or "" for no accelerator, or
- * %NULL to use the stock accelerator
- *
- * Adds an action object to the action group and sets up the accelerator.
- *
- * If @accelerator is %NULL, attempts to use the accelerator associated
- * with the stock_id of the action.
- *
- * Accel paths are set to
- * <literal><Actions>/<replaceable>group-name</replaceable>/<replaceable>action-name</replaceable></literal>.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-void
-gtk_action_group_add_action_with_accel (GtkActionGroup *action_group,
- GtkAction *action,
- const gchar *accelerator)
-{
- GtkActionGroupPrivate *private;
- gchar *accel_path;
- guint accel_key = 0;
- GdkModifierType accel_mods;
- const gchar *name;
-
- name = gtk_action_get_name (action);
- if (!check_unique_action (action_group, name))
- return;
-
- private = action_group->priv;
- accel_path = g_strconcat ("<Actions>/",
- private->name, "/", name, NULL);
-
- if (accelerator)
- {
- if (accelerator[0] == 0)
- accel_key = 0;
- else
- {
- gtk_accelerator_parse (accelerator, &accel_key, &accel_mods);
- if (accel_key == 0)
- g_warning ("Unable to parse accelerator '%s' for action '%s'",
- accelerator, name);
- }
- }
- else
- {
- gchar *stock_id;
- GtkStockItem stock_item;
-
- g_object_get (action, "stock-id", &stock_id, NULL);
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-
- if (stock_id && gtk_stock_lookup (stock_id, &stock_item))
- {
- accel_key = stock_item.keyval;
- accel_mods = stock_item.modifier;
- }
-
- G_GNUC_END_IGNORE_DEPRECATIONS;
-
- g_free (stock_id);
- }
-
- if (accel_key)
- gtk_accel_map_add_entry (accel_path, accel_key, accel_mods);
-
- gtk_action_set_accel_path (action, accel_path);
- gtk_action_group_add_action (action_group, action);
-
- g_free (accel_path);
-}
-
-/**
- * gtk_action_group_remove_action:
- * @action_group: the action group
- * @action: an action
- *
- * Removes an action object from the action group.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-void
-gtk_action_group_remove_action (GtkActionGroup *action_group,
- GtkAction *action)
-{
- GtkActionGroupPrivate *private;
- const gchar *name;
-
- g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
- g_return_if_fail (GTK_IS_ACTION (action));
-
- name = gtk_action_get_name (action);
- g_return_if_fail (name != NULL);
-
- private = action_group->priv;
-
- g_hash_table_remove (private->actions, name);
-}
-
-static void
-add_single_action (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- GList **list = user_data;
-
- *list = g_list_prepend (*list, value);
-}
-
-/**
- * gtk_action_group_list_actions:
- * @action_group: the action group
- *
- * Lists the actions in the action group.
- *
- * Returns: (element-type GtkAction) (transfer container): an allocated list of the action objects in the action group
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-GList *
-gtk_action_group_list_actions (GtkActionGroup *action_group)
-{
- GtkActionGroupPrivate *private;
- GList *actions = NULL;
-
- g_return_val_if_fail (GTK_IS_ACTION_GROUP (action_group), NULL);
-
- private = action_group->priv;
-
- g_hash_table_foreach (private->actions, add_single_action, &actions);
-
- return g_list_reverse (actions);
-}
-
-
-/**
- * gtk_action_group_add_actions: (skip)
- * @action_group: the action group
- * @entries: (array length=n_entries): an array of action descriptions
- * @n_entries: the number of entries
- * @user_data: data to pass to the action callbacks
- *
- * This is a convenience function to create a number of actions and add them
- * to the action group.
- *
- * The "activate" signals of the actions are connected to the callbacks and
- * their accel paths are set to
- * <literal><Actions>/<replaceable>group-name</replaceable>/<replaceable>action-name</replaceable></literal>.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-void
-gtk_action_group_add_actions (GtkActionGroup *action_group,
- const GtkActionEntry *entries,
- guint n_entries,
- gpointer user_data)
-{
- gtk_action_group_add_actions_full (action_group,
- entries, n_entries,
- user_data, NULL);
-}
-
-typedef struct _SharedData SharedData;
-
-struct _SharedData {
- guint ref_count;
- gpointer data;
- GDestroyNotify destroy;
-};
-
-static void
-shared_data_unref (gpointer data)
-{
- SharedData *shared_data = (SharedData *)data;
-
- shared_data->ref_count--;
- if (shared_data->ref_count == 0)
- {
- if (shared_data->destroy)
- shared_data->destroy (shared_data->data);
-
- g_slice_free (SharedData, shared_data);
- }
-}
-
-
-/**
- * gtk_action_group_add_actions_full: (skip)
- * @action_group: the action group
- * @entries: (array length=n_entries): an array of action descriptions
- * @n_entries: the number of entries
- * @user_data: data to pass to the action callbacks
- * @destroy: destroy notification callback for @user_data
- *
- * This variant of gtk_action_group_add_actions() adds a #GDestroyNotify
- * callback for @user_data.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-void
-gtk_action_group_add_actions_full (GtkActionGroup *action_group,
- const GtkActionEntry *entries,
- guint n_entries,
- gpointer user_data,
- GDestroyNotify destroy)
-{
-
- /* Keep this in sync with the other
- * gtk_action_group_add_..._actions_full() functions.
- */
- guint i;
- SharedData *shared_data;
-
- g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
-
- shared_data = g_slice_new0 (SharedData);
- shared_data->ref_count = 1;
- shared_data->data = user_data;
- shared_data->destroy = destroy;
-
- for (i = 0; i < n_entries; i++)
- {
- GtkAction *action;
- const gchar *label;
- const gchar *tooltip;
-
- if (!check_unique_action (action_group, entries[i].name))
- continue;
-
- label = gtk_action_group_translate_string (action_group, entries[i].label);
- tooltip = gtk_action_group_translate_string (action_group, entries[i].tooltip);
-
- action = gtk_action_new (entries[i].name,
- label,
- tooltip,
- NULL);
-
- if (entries[i].stock_id)
- {
- g_object_set (action, "stock-id", entries[i].stock_id, NULL);
- if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default (),
- entries[i].stock_id))
- g_object_set (action, "icon-name", entries[i].stock_id, NULL);
- }
-
- if (entries[i].callback)
- {
- GClosure *closure;
-
- closure = g_cclosure_new (entries[i].callback, user_data, NULL);
- g_closure_add_finalize_notifier (closure, shared_data,
- (GClosureNotify)shared_data_unref);
- shared_data->ref_count++;
-
- g_signal_connect_closure (action, "activate", closure, FALSE);
- }
-
- gtk_action_group_add_action_with_accel (action_group,
- action,
- entries[i].accelerator);
- g_object_unref (action);
- }
-
- shared_data_unref (shared_data);
-}
-
-/**
- * gtk_action_group_add_toggle_actions: (skip)
- * @action_group: the action group
- * @entries: (array length=n_entries): an array of toggle action descriptions
- * @n_entries: the number of entries
- * @user_data: data to pass to the action callbacks
- *
- * This is a convenience function to create a number of toggle actions and add them
- * to the action group.
- *
- * The "activate" signals of the actions are connected to the callbacks and
- * their accel paths are set to
- * <literal><Actions>/<replaceable>group-name</replaceable>/<replaceable>action-name</replaceable></literal>.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-void
-gtk_action_group_add_toggle_actions (GtkActionGroup *action_group,
- const GtkToggleActionEntry *entries,
- guint n_entries,
- gpointer user_data)
-{
- gtk_action_group_add_toggle_actions_full (action_group,
- entries, n_entries,
- user_data, NULL);
-}
-
-
-/**
- * gtk_action_group_add_toggle_actions_full: (skip)
- * @action_group: the action group
- * @entries: (array length=n_entries): an array of toggle action descriptions
- * @n_entries: the number of entries
- * @user_data: data to pass to the action callbacks
- * @destroy: destroy notification callback for @user_data
- *
- * This variant of gtk_action_group_add_toggle_actions() adds a
- * #GDestroyNotify callback for @user_data.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-void
-gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_group,
- const GtkToggleActionEntry *entries,
- guint n_entries,
- gpointer user_data,
- GDestroyNotify destroy)
-{
- /* Keep this in sync with the other
- * gtk_action_group_add_..._actions_full() functions.
- */
- guint i;
- SharedData *shared_data;
-
- g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
-
- shared_data = g_slice_new0 (SharedData);
- shared_data->ref_count = 1;
- shared_data->data = user_data;
- shared_data->destroy = destroy;
-
- for (i = 0; i < n_entries; i++)
- {
- GtkToggleAction *action;
- const gchar *label;
- const gchar *tooltip;
-
- if (!check_unique_action (action_group, entries[i].name))
- continue;
-
- label = gtk_action_group_translate_string (action_group, entries[i].label);
- tooltip = gtk_action_group_translate_string (action_group, entries[i].tooltip);
-
- action = gtk_toggle_action_new (entries[i].name,
- label,
- tooltip,
- NULL);
-
- if (entries[i].stock_id)
- {
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-
- if (gtk_icon_factory_lookup_default (entries[i].stock_id))
- g_object_set (action, "stock-id", entries[i].stock_id, NULL);
- else
- g_object_set (action, "icon-name", entries[i].stock_id, NULL);
-
- G_GNUC_END_IGNORE_DEPRECATIONS;
- }
-
- gtk_toggle_action_set_active (action, entries[i].is_active);
-
- if (entries[i].callback)
- {
- GClosure *closure;
-
- closure = g_cclosure_new (entries[i].callback, user_data, NULL);
- g_closure_add_finalize_notifier (closure, shared_data,
- (GClosureNotify)shared_data_unref);
- shared_data->ref_count++;
-
- g_signal_connect_closure (action, "activate", closure, FALSE);
- }
-
- gtk_action_group_add_action_with_accel (action_group,
- GTK_ACTION (action),
- entries[i].accelerator);
- g_object_unref (action);
- }
-
- shared_data_unref (shared_data);
-}
-
-/**
- * gtk_action_group_add_radio_actions: (skip)
- * @action_group: the action group
- * @entries: (array length=n_entries): an array of radio action descriptions
- * @n_entries: the number of entries
- * @value: the value of the action to activate initially, or -1 if
- * no action should be activated
- * @on_change: the callback to connect to the changed signal
- * @user_data: data to pass to the action callbacks
- *
- * This is a convenience routine to create a group of radio actions and
- * add them to the action group.
- *
- * The "changed" signal of the first radio action is connected to the
- * @on_change callback and the accel paths of the actions are set to
- * <literal><Actions>/<replaceable>group-name</replaceable>/<replaceable>action-name</replaceable></literal>.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-void
-gtk_action_group_add_radio_actions (GtkActionGroup *action_group,
- const GtkRadioActionEntry *entries,
- guint n_entries,
- gint value,
- GCallback on_change,
- gpointer user_data)
-{
- gtk_action_group_add_radio_actions_full (action_group,
- entries, n_entries,
- value,
- on_change, user_data, NULL);
-}
-
-/**
- * gtk_action_group_add_radio_actions_full: (skip)
- * @action_group: the action group
- * @entries: (array length=n_entries): an array of radio action descriptions
- * @n_entries: the number of entries
- * @value: the value of the action to activate initially, or -1 if
- * no action should be activated
- * @on_change: the callback to connect to the changed signal
- * @user_data: data to pass to the action callbacks
- * @destroy: destroy notification callback for @user_data
- *
- * This variant of gtk_action_group_add_radio_actions() adds a
- * #GDestroyNotify callback for @user_data.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-void
-gtk_action_group_add_radio_actions_full (GtkActionGroup *action_group,
- const GtkRadioActionEntry *entries,
- guint n_entries,
- gint value,
- GCallback on_change,
- gpointer user_data,
- GDestroyNotify destroy)
-{
- /* Keep this in sync with the other
- * gtk_action_group_add_..._actions_full() functions.
- */
- guint i;
- GSList *group = NULL;
- GtkRadioAction *first_action = NULL;
-
- g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
-
- for (i = 0; i < n_entries; i++)
- {
- GtkRadioAction *action;
- const gchar *label;
- const gchar *tooltip;
-
- if (!check_unique_action (action_group, entries[i].name))
- continue;
-
- label = gtk_action_group_translate_string (action_group, entries[i].label);
- tooltip = gtk_action_group_translate_string (action_group, entries[i].tooltip);
-
- action = gtk_radio_action_new (entries[i].name,
- label,
- tooltip,
- NULL,
- entries[i].value);
-
- if (entries[i].stock_id)
- {
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-
- if (gtk_icon_factory_lookup_default (entries[i].stock_id))
- g_object_set (action, "stock-id", entries[i].stock_id, NULL);
- else
- g_object_set (action, "icon-name", entries[i].stock_id, NULL);
-
- G_GNUC_END_IGNORE_DEPRECATIONS;
- }
-
- if (i == 0)
- first_action = action;
-
- gtk_radio_action_set_group (action, group);
- group = gtk_radio_action_get_group (action);
-
- if (value == entries[i].value)
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
-
- gtk_action_group_add_action_with_accel (action_group,
- GTK_ACTION (action),
- entries[i].accelerator);
- g_object_unref (action);
- }
-
- if (on_change && first_action)
- g_signal_connect_data (first_action, "changed",
- on_change, user_data,
- (GClosureNotify)destroy, 0);
-}
-
-/**
- * gtk_action_group_set_translate_func:
- * @action_group: a #GtkActionGroup
- * @func: a #GtkTranslateFunc
- * @data: data to be passed to @func and @notify
- * @notify: a #GDestroyNotify function to be called when @action_group is
- * destroyed and when the translation function is changed again
- *
- * Sets a function to be used for translating the @label and @tooltip of
- * #GtkActionEntry<!-- -->s added by gtk_action_group_add_actions().
- *
- * If you're using gettext(), it is enough to set the translation domain
- * with gtk_action_group_set_translation_domain().
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-void
-gtk_action_group_set_translate_func (GtkActionGroup *action_group,
- GtkTranslateFunc func,
- gpointer data,
- GDestroyNotify notify)
-{
- GtkActionGroupPrivate *private;
-
- g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
-
- private = action_group->priv;
-
- if (private->translate_notify)
- private->translate_notify (private->translate_data);
-
- private->translate_func = func;
- private->translate_data = data;
- private->translate_notify = notify;
-}
-
-static gchar *
-dgettext_swapped (const gchar *msgid,
- const gchar *domainname)
-{
- /* Pass through g_dgettext if and only if msgid is nonempty. */
- if (msgid && *msgid)
- return (gchar*) g_dgettext (domainname, msgid);
- else
- return (gchar*) msgid;
-}
-
-/**
- * gtk_action_group_set_translation_domain:
- * @action_group: a #GtkActionGroup
- * @domain: (allow-none): the translation domain to use for g_dgettext()
- * calls, or %NULL to use the domain set with textdomain()
- *
- * Sets the translation domain and uses g_dgettext() for translating the
- * @label and @tooltip of #GtkActionEntry<!-- -->s added by
- * gtk_action_group_add_actions().
- *
- * If you're not using gettext() for localization, see
- * gtk_action_group_set_translate_func().
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-void
-gtk_action_group_set_translation_domain (GtkActionGroup *action_group,
- const gchar *domain)
-{
- g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
-
- gtk_action_group_set_translate_func (action_group,
- (GtkTranslateFunc)dgettext_swapped,
- g_strdup (domain),
- g_free);
-}
-
-
-/**
- * gtk_action_group_translate_string:
- * @action_group: a #GtkActionGroup
- * @string: a string
- *
- * Translates a string using the function set with
- * gtk_action_group_set_translate_func(). This
- * is mainly intended for language bindings.
- *
- * Returns: the translation of @string
- *
- * Since: 2.6
- *
- * Deprecated: 3.10
- **/
-const gchar *
-gtk_action_group_translate_string (GtkActionGroup *action_group,
- const gchar *string)
-{
- GtkActionGroupPrivate *private;
- GtkTranslateFunc translate_func;
- gpointer translate_data;
-
- g_return_val_if_fail (GTK_IS_ACTION_GROUP (action_group), string);
-
- if (string == NULL)
- return NULL;
-
- private = action_group->priv;
-
- translate_func = private->translate_func;
- translate_data = private->translate_data;
-
- if (translate_func)
- return translate_func (string, translate_data);
- else
- return string;
-}
-
-/* Protected for use by GtkAction */
-void
-_gtk_action_group_emit_connect_proxy (GtkActionGroup *action_group,
- GtkAction *action,
- GtkWidget *proxy)
-{
- g_signal_emit (action_group, action_group_signals[CONNECT_PROXY], 0,
- action, proxy);
-}
-
-void
-_gtk_action_group_emit_disconnect_proxy (GtkActionGroup *action_group,
- GtkAction *action,
- GtkWidget *proxy)
-{
- g_signal_emit (action_group, action_group_signals[DISCONNECT_PROXY], 0,
- action, proxy);
-}
-
-void
-_gtk_action_group_emit_pre_activate (GtkActionGroup *action_group,
- GtkAction *action)
-{
- g_signal_emit (action_group, action_group_signals[PRE_ACTIVATE], 0, action);
-}
-
-void
-_gtk_action_group_emit_post_activate (GtkActionGroup *action_group,
- GtkAction *action)
-{
- g_signal_emit (action_group, action_group_signals[POST_ACTIVATE], 0, action);
-}
+++ /dev/null
-/*
- * GTK - The GIMP Toolkit
- * Copyright (C) 1998, 1999 Red Hat, Inc.
- * All rights reserved.
- *
- * This Library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This Library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Author: James Henstridge <james@daa.com.au>
- *
- * Modified by the GTK+ Team and others 2003. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#ifndef __GTK_ACTION_GROUP_H__
-#define __GTK_ACTION_GROUP_H__
-
-#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
-#error "Only <gtk/gtk.h> can be included directly."
-#endif
-
-#include <gtk/gtkaction.h>
-#include <gtk/gtkstock.h>
-
-G_BEGIN_DECLS
-
-#define GTK_TYPE_ACTION_GROUP (gtk_action_group_get_type ())
-#define GTK_ACTION_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ACTION_GROUP, GtkActionGroup))
-#define GTK_ACTION_GROUP_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), GTK_TYPE_ACTION_GROUP, GtkActionGroupClass))
-#define GTK_IS_ACTION_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ACTION_GROUP))
-#define GTK_IS_ACTION_GROUP_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), GTK_TYPE_ACTION_GROUP))
-#define GTK_ACTION_GROUP_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), GTK_TYPE_ACTION_GROUP, GtkActionGroupClass))
-
-typedef struct _GtkActionGroup GtkActionGroup;
-typedef struct _GtkActionGroupPrivate GtkActionGroupPrivate;
-typedef struct _GtkActionGroupClass GtkActionGroupClass;
-typedef struct _GtkActionEntry GtkActionEntry;
-typedef struct _GtkToggleActionEntry GtkToggleActionEntry;
-typedef struct _GtkRadioActionEntry GtkRadioActionEntry;
-
-struct _GtkActionGroup
-{
- GObject parent;
-
- /*< private >*/
- GtkActionGroupPrivate *priv;
-};
-
-struct _GtkActionGroupClass
-{
- GObjectClass parent_class;
-
- GtkAction *(* get_action) (GtkActionGroup *action_group,
- const gchar *action_name);
-
- /* Padding for future expansion */
- void (*_gtk_reserved1) (void);
- void (*_gtk_reserved2) (void);
- void (*_gtk_reserved3) (void);
- void (*_gtk_reserved4) (void);
-};
-
-/**
- * GtkActionEntry:
- * @name: The name of the action.
- * @stock_id: The stock id for the action, or the name of an icon from the
- * icon theme.
- * @label: The label for the action. This field should typically be marked
- * for translation, see gtk_action_group_set_translation_domain(). If
- * @label is %NULL, the label of the stock item with id @stock_id is used.
- * @accelerator: The accelerator for the action, in the format understood by
- * gtk_accelerator_parse().
- * @tooltip: The tooltip for the action. This field should typically be
- * marked for translation, see gtk_action_group_set_translation_domain().
- * @callback: The function to call when the action is activated.
- *
- * #GtkActionEntry structs are used with gtk_action_group_add_actions() to
- * construct actions.
- *
- * Deprecated: 3.10
- */
-struct _GtkActionEntry
-{
- const gchar *name;
- const gchar *stock_id;
- const gchar *label;
- const gchar *accelerator;
- const gchar *tooltip;
- GCallback callback;
-};
-
-/**
- * GtkToggleActionEntry:
- * @name: The name of the action.
- * @stock_id: The stock id for the action, or the name of an icon from the
- * icon theme.
- * @label: The label for the action. This field should typically be marked
- * for translation, see gtk_action_group_set_translation_domain().
- * @accelerator: The accelerator for the action, in the format understood by
- * gtk_accelerator_parse().
- * @tooltip: The tooltip for the action. This field should typically be
- * marked for translation, see gtk_action_group_set_translation_domain().
- * @callback: The function to call when the action is activated.
- * @is_active: The initial state of the toggle action.
- *
- * #GtkToggleActionEntry structs are used with
- * gtk_action_group_add_toggle_actions() to construct toggle actions.
- *
- * Deprecated: 3.10
- */
-struct _GtkToggleActionEntry
-{
- const gchar *name;
- const gchar *stock_id;
- const gchar *label;
- const gchar *accelerator;
- const gchar *tooltip;
- GCallback callback;
- gboolean is_active;
-};
-
-/**
- * GtkRadioActionEntry:
- * @name: The name of the action.
- * @stock_id: The stock id for the action, or the name of an icon from the
- * icon theme.
- * @label: The label for the action. This field should typically be marked
- * for translation, see gtk_action_group_set_translation_domain().
- * @accelerator: The accelerator for the action, in the format understood by
- * gtk_accelerator_parse().
- * @tooltip: The tooltip for the action. This field should typically be
- * marked for translation, see gtk_action_group_set_translation_domain().
- * @value: The value to set on the radio action. See
- * gtk_radio_action_get_current_value().
- *
- * #GtkRadioActionEntry structs are used with
- * gtk_action_group_add_radio_actions() to construct groups of radio actions.
- *
- * Deprecated: 3.10
- */
-struct _GtkRadioActionEntry
-{
- const gchar *name;
- const gchar *stock_id;
- const gchar *label;
- const gchar *accelerator;
- const gchar *tooltip;
- gint value;
-};
-
-GDK_DEPRECATED_IN_3_10
-GType gtk_action_group_get_type (void) G_GNUC_CONST;
-GDK_DEPRECATED_IN_3_10
-GtkActionGroup *gtk_action_group_new (const gchar *name);
-GDK_DEPRECATED_IN_3_10
-const gchar *gtk_action_group_get_name (GtkActionGroup *action_group);
-GDK_DEPRECATED_IN_3_10
-gboolean gtk_action_group_get_sensitive (GtkActionGroup *action_group);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_group_set_sensitive (GtkActionGroup *action_group,
- gboolean sensitive);
-GDK_DEPRECATED_IN_3_10
-gboolean gtk_action_group_get_visible (GtkActionGroup *action_group);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_group_set_visible (GtkActionGroup *action_group,
- gboolean visible);
-GDK_DEPRECATED_IN_3_10
-GtkAccelGroup *gtk_action_group_get_accel_group (GtkActionGroup *action_group);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_group_set_accel_group (GtkActionGroup *action_group,
- GtkAccelGroup *accel_group);
-
-GDK_DEPRECATED_IN_3_10
-GtkAction *gtk_action_group_get_action (GtkActionGroup *action_group,
- const gchar *action_name);
-GDK_DEPRECATED_IN_3_10
-GList *gtk_action_group_list_actions (GtkActionGroup *action_group);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_group_add_action (GtkActionGroup *action_group,
- GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_group_add_action_with_accel (GtkActionGroup *action_group,
- GtkAction *action,
- const gchar *accelerator);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_group_remove_action (GtkActionGroup *action_group,
- GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_group_add_actions (GtkActionGroup *action_group,
- const GtkActionEntry *entries,
- guint n_entries,
- gpointer user_data);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_group_add_toggle_actions (GtkActionGroup *action_group,
- const GtkToggleActionEntry *entries,
- guint n_entries,
- gpointer user_data);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_group_add_radio_actions (GtkActionGroup *action_group,
- const GtkRadioActionEntry *entries,
- guint n_entries,
- gint value,
- GCallback on_change,
- gpointer user_data);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_group_add_actions_full (GtkActionGroup *action_group,
- const GtkActionEntry *entries,
- guint n_entries,
- gpointer user_data,
- GDestroyNotify destroy);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_group,
- const GtkToggleActionEntry *entries,
- guint n_entries,
- gpointer user_data,
- GDestroyNotify destroy);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_group_add_radio_actions_full (GtkActionGroup *action_group,
- const GtkRadioActionEntry *entries,
- guint n_entries,
- gint value,
- GCallback on_change,
- gpointer user_data,
- GDestroyNotify destroy);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_group_set_translate_func (GtkActionGroup *action_group,
- GtkTranslateFunc func,
- gpointer data,
- GDestroyNotify notify);
-GDK_DEPRECATED_IN_3_10
-void gtk_action_group_set_translation_domain (GtkActionGroup *action_group,
- const gchar *domain);
-GDK_DEPRECATED_IN_3_10
-const gchar * gtk_action_group_translate_string (GtkActionGroup *action_group,
- const gchar *string);
-
-/* Protected for use by GtkAction */
-void _gtk_action_group_emit_connect_proxy (GtkActionGroup *action_group,
- GtkAction *action,
- GtkWidget *proxy);
-void _gtk_action_group_emit_disconnect_proxy (GtkActionGroup *action_group,
- GtkAction *action,
- GtkWidget *proxy);
-void _gtk_action_group_emit_pre_activate (GtkActionGroup *action_group,
- GtkAction *action);
-void _gtk_action_group_emit_post_activate (GtkActionGroup *action_group,
- GtkAction *action);
-
-G_END_DECLS
-
-#endif /* __GTK_ACTION_GROUP_H__ */
+++ /dev/null
-/* gtkactivatable.c
- * Copyright (C) 2008 Tristan Van Berkom <tristan.van.berkom@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/**
- * SECTION:gtkactivatable
- * @Short_Description: An interface for activatable widgets
- * @Title: GtkActivatable
- *
- * Activatable widgets can be connected to a #GtkAction and reflects
- * the state of its action. A #GtkActivatable can also provide feedback
- * through its action, as they are responsible for activating their
- * related actions.
- *
- * <refsect2>
- * <title>Implementing GtkActivatable</title>
- * <para>
- * When extending a class that is already #GtkActivatable; it is only
- * necessary to implement the #GtkActivatable->sync_action_properties()
- * and #GtkActivatable->update() methods and chain up to the parent
- * implementation, however when introducing
- * a new #GtkActivatable class; the #GtkActivatable:related-action and
- * #GtkActivatable:use-action-appearance properties need to be handled by
- * the implementor. Handling these properties is mostly a matter of installing
- * the action pointer and boolean flag on your instance, and calling
- * gtk_activatable_do_set_related_action() and
- * gtk_activatable_sync_action_properties() at the appropriate times.
- * </para>
- * <example>
- * <title>A class fragment implementing #GtkActivatable</title>
- * <programlisting><![CDATA[
- *
- * enum {
- * ...
- *
- * PROP_ACTIVATABLE_RELATED_ACTION,
- * PROP_ACTIVATABLE_USE_ACTION_APPEARANCE
- * }
- *
- * struct _FooBarPrivate
- * {
- *
- * ...
- *
- * GtkAction *action;
- * gboolean use_action_appearance;
- * };
- *
- * ...
- *
- * static void foo_bar_activatable_interface_init (GtkActivatableIface *iface);
- * static void foo_bar_activatable_update (GtkActivatable *activatable,
- * GtkAction *action,
- * const gchar *property_name);
- * static void foo_bar_activatable_sync_action_properties (GtkActivatable *activatable,
- * GtkAction *action);
- * ...
- *
- *
- * static void
- * foo_bar_class_init (FooBarClass *klass)
- * {
- *
- * ...
- *
- * g_object_class_override_property (gobject_class, PROP_ACTIVATABLE_RELATED_ACTION, "related-action");
- * g_object_class_override_property (gobject_class, PROP_ACTIVATABLE_USE_ACTION_APPEARANCE, "use-action-appearance");
- *
- * ...
- * }
- *
- *
- * static void
- * foo_bar_activatable_interface_init (GtkActivatableIface *iface)
- * {
- * iface->update = foo_bar_activatable_update;
- * iface->sync_action_properties = foo_bar_activatable_sync_action_properties;
- * }
- *
- * ... Break the reference using gtk_activatable_do_set_related_action()...
- *
- * static void
- * foo_bar_dispose (GObject *object)
- * {
- * FooBar *bar = FOO_BAR (object);
- * FooBarPrivate *priv = FOO_BAR_GET_PRIVATE (bar);
- *
- * ...
- *
- * if (priv->action)
- * {
- * gtk_activatable_do_set_related_action (GTK_ACTIVATABLE (bar), NULL);
- * priv->action = NULL;
- * }
- * G_OBJECT_CLASS (foo_bar_parent_class)->dispose (object);
- * }
- *
- * ... Handle the "related-action" and "use-action-appearance" properties ...
- *
- * static void
- * foo_bar_set_property (GObject *object,
- * guint prop_id,
- * const GValue *value,
- * GParamSpec *pspec)
- * {
- * FooBar *bar = FOO_BAR (object);
- * FooBarPrivate *priv = FOO_BAR_GET_PRIVATE (bar);
- *
- * switch (prop_id)
- * {
- *
- * ...
- *
- * case PROP_ACTIVATABLE_RELATED_ACTION:
- * foo_bar_set_related_action (bar, g_value_get_object (value));
- * break;
- * case PROP_ACTIVATABLE_USE_ACTION_APPEARANCE:
- * foo_bar_set_use_action_appearance (bar, g_value_get_boolean (value));
- * break;
- * default:
- * G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- * break;
- * }
- * }
- *
- * static void
- * foo_bar_get_property (GObject *object,
- * guint prop_id,
- * GValue *value,
- * GParamSpec *pspec)
- * {
- * FooBar *bar = FOO_BAR (object);
- * FooBarPrivate *priv = FOO_BAR_GET_PRIVATE (bar);
- *
- * switch (prop_id)
- * {
- *
- * ...
- *
- * case PROP_ACTIVATABLE_RELATED_ACTION:
- * g_value_set_object (value, priv->action);
- * break;
- * case PROP_ACTIVATABLE_USE_ACTION_APPEARANCE:
- * g_value_set_boolean (value, priv->use_action_appearance);
- * break;
- * default:
- * G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- * break;
- * }
- * }
- *
- *
- * static void
- * foo_bar_set_use_action_appearance (FooBar *bar,
- * gboolean use_appearance)
- * {
- * FooBarPrivate *priv = FOO_BAR_GET_PRIVATE (bar);
- *
- * if (priv->use_action_appearance != use_appearance)
- * {
- * priv->use_action_appearance = use_appearance;
- *
- * gtk_activatable_sync_action_properties (GTK_ACTIVATABLE (bar), priv->action);
- * }
- * }
- *
- * ... call gtk_activatable_do_set_related_action() and then assign the action pointer,
- * no need to reference the action here since gtk_activatable_do_set_related_action() already
- * holds a reference here for you...
- * static void
- * foo_bar_set_related_action (FooBar *bar,
- * GtkAction *action)
- * {
- * FooBarPrivate *priv = FOO_BAR_GET_PRIVATE (bar);
- *
- * if (priv->action == action)
- * return;
- *
- * gtk_activatable_do_set_related_action (GTK_ACTIVATABLE (bar), action);
- *
- * priv->action = action;
- * }
- *
- * ... Selectively reset and update activatable depending on the use-action-appearance property ...
- * static void
- * gtk_button_activatable_sync_action_properties (GtkActivatable *activatable,
- * GtkAction *action)
- * {
- * GtkButtonPrivate *priv = GTK_BUTTON_GET_PRIVATE (activatable);
- *
- * if (!action)
- * return;
- *
- * if (gtk_action_is_visible (action))
- * gtk_widget_show (GTK_WIDGET (activatable));
- * else
- * gtk_widget_hide (GTK_WIDGET (activatable));
- *
- * gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action));
- *
- * ...
- *
- * if (priv->use_action_appearance)
- * {
- * if (gtk_action_get_stock_id (action))
- * foo_bar_set_stock (button, gtk_action_get_stock_id (action));
- * else if (gtk_action_get_label (action))
- * foo_bar_set_label (button, gtk_action_get_label (action));
- *
- * ...
- *
- * }
- * }
- *
- * static void
- * foo_bar_activatable_update (GtkActivatable *activatable,
- * GtkAction *action,
- * const gchar *property_name)
- * {
- * FooBarPrivate *priv = FOO_BAR_GET_PRIVATE (activatable);
- *
- * if (strcmp (property_name, "visible") == 0)
- * {
- * if (gtk_action_is_visible (action))
- * gtk_widget_show (GTK_WIDGET (activatable));
- * else
- * gtk_widget_hide (GTK_WIDGET (activatable));
- * }
- * else if (strcmp (property_name, "sensitive") == 0)
- * gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action));
- *
- * ...
- *
- * if (!priv->use_action_appearance)
- * return;
- *
- * if (strcmp (property_name, "stock-id") == 0)
- * foo_bar_set_stock (button, gtk_action_get_stock_id (action));
- * else if (strcmp (property_name, "label") == 0)
- * foo_bar_set_label (button, gtk_action_get_label (action));
- *
- * ...
- * }]]></programlisting>
- * </example>
- * </refsect2>
- */
-
-#include "config.h"
-#define GDK_DISABLE_DEPRECATION_WARNINGS
-#include "gtkactivatable.h"
-#include "gtkactiongroup.h"
-#include "gtkprivate.h"
-#include "gtkintl.h"
-
-
-typedef GtkActivatableIface GtkActivatableInterface;
-G_DEFINE_INTERFACE (GtkActivatable, gtk_activatable, G_TYPE_OBJECT)
-
-static void
-gtk_activatable_default_init (GtkActivatableInterface *iface)
-{
- /**
- * GtkActivatable:related-action:
- *
- * The action that this activatable will activate and receive
- * updates from for various states and possibly appearance.
- *
- * <note><para>#GtkActivatable implementors need to handle the this property and
- * call gtk_activatable_do_set_related_action() when it changes.</para></note>
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
- g_object_interface_install_property (iface,
- g_param_spec_object ("related-action",
- P_("Related Action"),
- P_("The action this activatable will activate and receive updates from"),
- GTK_TYPE_ACTION,
- GTK_PARAM_READWRITE));
-
- /**
- * GtkActivatable:use-action-appearance:
- *
- * Whether this activatable should reset its layout
- * and appearance when setting the related action or when
- * the action changes appearance.
- *
- * See the #GtkAction documentation directly to find which properties
- * should be ignored by the #GtkActivatable when this property is %FALSE.
- *
- * <note><para>#GtkActivatable implementors need to handle this property
- * and call gtk_activatable_sync_action_properties() on the activatable
- * widget when it changes.</para></note>
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
- g_object_interface_install_property (iface,
- g_param_spec_boolean ("use-action-appearance",
- P_("Use Action Appearance"),
- P_("Whether to use the related actions appearance properties"),
- TRUE,
- GTK_PARAM_READWRITE));
-
-
-}
-
-static void
-gtk_activatable_update (GtkActivatable *activatable,
- GtkAction *action,
- const gchar *property_name)
-{
- GtkActivatableIface *iface;
-
- g_return_if_fail (GTK_IS_ACTIVATABLE (activatable));
-
- iface = GTK_ACTIVATABLE_GET_IFACE (activatable);
- if (iface->update)
- iface->update (activatable, action, property_name);
- else
- g_critical ("GtkActivatable->update() unimplemented for type %s",
- g_type_name (G_OBJECT_TYPE (activatable)));
-}
-
-/**
- * gtk_activatable_sync_action_properties:
- * @activatable: a #GtkActivatable
- * @action: (allow-none): the related #GtkAction or %NULL
- *
- * This is called to update the activatable completely, this is called
- * internally when the #GtkActivatable:related-action property is set
- * or unset and by the implementing class when
- * #GtkActivatable:use-action-appearance changes.
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- **/
-void
-gtk_activatable_sync_action_properties (GtkActivatable *activatable,
- GtkAction *action)
-{
- GtkActivatableIface *iface;
-
- g_return_if_fail (GTK_IS_ACTIVATABLE (activatable));
-
- iface = GTK_ACTIVATABLE_GET_IFACE (activatable);
- if (iface->sync_action_properties)
- iface->sync_action_properties (activatable, action);
- else
- g_critical ("GtkActivatable->sync_action_properties() unimplemented for type %s",
- g_type_name (G_OBJECT_TYPE (activatable)));
-}
-
-
-/**
- * gtk_activatable_set_related_action:
- * @activatable: a #GtkActivatable
- * @action: the #GtkAction to set
- *
- * Sets the related action on the @activatable object.
- *
- * <note><para>#GtkActivatable implementors need to handle the #GtkActivatable:related-action
- * property and call gtk_activatable_do_set_related_action() when it changes.</para></note>
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- **/
-void
-gtk_activatable_set_related_action (GtkActivatable *activatable,
- GtkAction *action)
-{
- g_return_if_fail (GTK_IS_ACTIVATABLE (activatable));
- g_return_if_fail (action == NULL || GTK_IS_ACTION (action));
-
- g_object_set (activatable, "related-action", action, NULL);
-}
-
-static void
-gtk_activatable_action_notify (GtkAction *action,
- GParamSpec *pspec,
- GtkActivatable *activatable)
-{
- gtk_activatable_update (activatable, action, pspec->name);
-}
-
-/**
- * gtk_activatable_do_set_related_action:
- * @activatable: a #GtkActivatable
- * @action: the #GtkAction to set
- *
- * This is a utility function for #GtkActivatable implementors.
- *
- * When implementing #GtkActivatable you must call this when
- * handling changes of the #GtkActivatable:related-action, and
- * you must also use this to break references in #GObject->dispose().
- *
- * This function adds a reference to the currently set related
- * action for you, it also makes sure the #GtkActivatable->update()
- * method is called when the related #GtkAction properties change
- * and registers to the action's proxy list.
- *
- * <note><para>Be careful to call this before setting the local
- * copy of the #GtkAction property, since this function uses
- * gtk_activatable_get_related_action() to retrieve the
- * previous action</para></note>
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-void
-gtk_activatable_do_set_related_action (GtkActivatable *activatable,
- GtkAction *action)
-{
- GtkAction *prev_action;
-
- prev_action = gtk_activatable_get_related_action (activatable);
-
- if (prev_action != action)
- {
- if (prev_action)
- {
- g_signal_handlers_disconnect_by_func (prev_action, gtk_activatable_action_notify, activatable);
-
- /* Check the type so that actions can be activatable too. */
- if (GTK_IS_WIDGET (activatable))
- _gtk_action_remove_from_proxy_list (prev_action, GTK_WIDGET (activatable));
-
- /* Some apps are using the object data directly...
- * so continue to set it for a bit longer
- */
- g_object_set_data (G_OBJECT (activatable), "gtk-action", NULL);
-
- /*
- * We don't want prev_action to be activated
- * during the sync_action_properties() call when syncing "active".
- */
- gtk_action_block_activate (prev_action);
- }
-
- /* Some applications rely on their proxy UI to be set up
- * before they receive the ::connect-proxy signal, so we
- * need to call sync_action_properties() before add_to_proxy_list().
- */
- gtk_activatable_sync_action_properties (activatable, action);
-
- if (prev_action)
- {
- gtk_action_unblock_activate (prev_action);
- g_object_unref (prev_action);
- }
-
- if (action)
- {
- g_object_ref (action);
-
- g_signal_connect (G_OBJECT (action), "notify", G_CALLBACK (gtk_activatable_action_notify), activatable);
-
- if (GTK_IS_WIDGET (activatable))
- _gtk_action_add_to_proxy_list (action, GTK_WIDGET (activatable));
-
- g_object_set_data (G_OBJECT (activatable), "gtk-action", action);
- }
- }
-}
-
-/**
- * gtk_activatable_get_related_action:
- * @activatable: a #GtkActivatable
- *
- * Gets the related #GtkAction for @activatable.
- *
- * Returns: (transfer none): the related #GtkAction if one is set.
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- **/
-GtkAction *
-gtk_activatable_get_related_action (GtkActivatable *activatable)
-{
- GtkAction *action;
-
- g_return_val_if_fail (GTK_IS_ACTIVATABLE (activatable), NULL);
-
- g_object_get (activatable, "related-action", &action, NULL);
-
- /* g_object_get() gives us a ref... */
- if (action)
- g_object_unref (action);
-
- return action;
-}
-
-/**
- * gtk_activatable_set_use_action_appearance:
- * @activatable: a #GtkActivatable
- * @use_appearance: whether to use the actions appearance
- *
- * Sets whether this activatable should reset its layout and appearance
- * when setting the related action or when the action changes appearance
- *
- * <note><para>#GtkActivatable implementors need to handle the
- * #GtkActivatable:use-action-appearance property and call
- * gtk_activatable_sync_action_properties() to update @activatable
- * if needed.</para></note>
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
-**/
-void
-gtk_activatable_set_use_action_appearance (GtkActivatable *activatable,
- gboolean use_appearance)
-{
- g_object_set (activatable, "use-action-appearance", use_appearance, NULL);
-}
-
-/**
- * gtk_activatable_get_use_action_appearance:
- * @activatable: a #GtkActivatable
- *
- * Gets whether this activatable should reset its layout
- * and appearance when setting the related action or when
- * the action changes appearance.
- *
- * Returns: whether @activatable uses its actions appearance.
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
-**/
-gboolean
-gtk_activatable_get_use_action_appearance (GtkActivatable *activatable)
-{
- gboolean use_appearance;
-
- g_object_get (activatable, "use-action-appearance", &use_appearance, NULL);
-
- return use_appearance;
-}
+++ /dev/null
-/* GTK - The GIMP Toolkit
- * Copyright (C) 2008 Tristan Van Berkom <tristan.van.berkom@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __GTK_ACTIVATABLE_H__
-#define __GTK_ACTIVATABLE_H__
-
-#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
-#error "Only <gtk/gtk.h> can be included directly."
-#endif
-
-#include <gtk/gtkaction.h>
-
-G_BEGIN_DECLS
-
-#define GTK_TYPE_ACTIVATABLE (gtk_activatable_get_type ())
-#define GTK_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ACTIVATABLE, GtkActivatable))
-#define GTK_ACTIVATABLE_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), GTK_TYPE_ACTIVATABLE, GtkActivatableIface))
-#define GTK_IS_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ACTIVATABLE))
-#define GTK_ACTIVATABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_ACTIVATABLE, GtkActivatableIface))
-
-
-typedef struct _GtkActivatable GtkActivatable; /* Dummy typedef */
-typedef struct _GtkActivatableIface GtkActivatableIface;
-
-
-/**
- * GtkActivatableIface:
- * @update: Called to update the activatable when its related action's properties change.
- * You must check the #GtkActivatable:use-action-appearance property only apply action
- * properties that are meant to effect the appearance accordingly.
- * @sync_action_properties: Called to update the activatable completely, this is called internally when
- * #GtkActivatable:related-action property is set or unset and by the implementor when
- * #GtkActivatable:use-action-appearance changes.<note><para>This method can be called
- * with a %NULL action at times</para></note>
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-
-struct _GtkActivatableIface
-{
- GTypeInterface g_iface;
-
- /* virtual table */
- void (* update) (GtkActivatable *activatable,
- GtkAction *action,
- const gchar *property_name);
- void (* sync_action_properties) (GtkActivatable *activatable,
- GtkAction *action);
-};
-
-
-GDK_DEPRECATED_IN_3_10
-GType gtk_activatable_get_type (void) G_GNUC_CONST;
-
-GDK_DEPRECATED_IN_3_10
-void gtk_activatable_sync_action_properties (GtkActivatable *activatable,
- GtkAction *action);
-
-GDK_DEPRECATED_IN_3_10
-void gtk_activatable_set_related_action (GtkActivatable *activatable,
- GtkAction *action);
-GDK_DEPRECATED_IN_3_10
-GtkAction *gtk_activatable_get_related_action (GtkActivatable *activatable);
-
-GDK_DEPRECATED_IN_3_10
-void gtk_activatable_set_use_action_appearance (GtkActivatable *activatable,
- gboolean use_appearance);
-GDK_DEPRECATED_IN_3_10
-gboolean gtk_activatable_get_use_action_appearance (GtkActivatable *activatable);
-
-/* For use in activatable implementations */
-GDK_DEPRECATED_IN_3_10
-void gtk_activatable_do_set_related_action (GtkActivatable *activatable,
- GtkAction *action);
-
-G_END_DECLS
-
-#endif /* __GTK_ACTIVATABLE_H__ */
#include "gtkbbox.h"
#include "gtkbutton.h"
#include "gtkmenuitem.h"
-#include "gtkstock.h"
+#include "deprecated/gtkstock.h"
#include <string.h>
#include <glib/gi18n-lib.h>
#include "gtktypebuiltins.h"
#include "gtkwindow.h"
#include "gtkicontheme.h"
-#include "gtkstock.h"
+#include "deprecated/gtkstock.h"
static void gtk_builder_class_init (GtkBuilderClass *klass);
#include "gtkmarshalers.h"
#include "gtkimage.h"
#include "gtkbox.h"
-#include "gtkstock.h"
-#include "gtkiconfactory.h"
-#include "gtkactivatable.h"
+#include "deprecated/gtkstock.h"
+#include "deprecated/gtkiconfactory.h"
+#include "deprecated/gtkactivatable.h"
#include "gtksizerequest.h"
#include "gtktypebuiltins.h"
#include "gtkwidgetprivate.h"
#define __GTK_BUTTON_PRIVATE_H__
#include "gtkactionhelper.h"
-#include "gtkaction.h"
+#include "deprecated/gtkaction.h"
G_BEGIN_DECLS
#include <stdlib.h>
#include <cairo-gobject.h>
#include "gtkcellrendererpixbuf.h"
-#include "gtkiconfactory.h"
+#include "deprecated/gtkiconfactory.h"
#include "gtkiconhelperprivate.h"
#include "gtkicontheme.h"
#include "gtkintl.h"
#include "config.h"
#include "gtkcellrendererspinner.h"
-#include "gtkiconfactory.h"
+#include "deprecated/gtkiconfactory.h"
#include "gtkicontheme.h"
#include "gtkintl.h"
#include "gtksettings.h"
#include "gtkcheckmenuitem.h"
#include "gtkmenuitemprivate.h"
#include "gtkaccellabel.h"
-#include "gtkactivatable.h"
-#include "gtktoggleaction.h"
+#include "deprecated/gtkactivatable.h"
+#include "deprecated/gtktoggleaction.h"
#include "gtkmarshalers.h"
#include "gtkprivate.h"
#include "gtkintl.h"
#include "gtkprivate.h"
#include "gtkbuildable.h"
#include "gtksettings.h"
-#include "gtkstock.h"
+#include "deprecated/gtkstock.h"
/**
* SECTION:gtkdialog
#include "gdk/gdk.h"
#include "gtkdnd.h"
-#include "gtkiconfactory.h"
+#include "deprecated/gtkiconfactory.h"
#include "gtkicontheme.h"
#include "gtkimageprivate.h"
#include "gtkinvisible.h"
#endif
#include "gtkdnd.h"
-#include "gtkiconfactory.h"
+#include "deprecated/gtkiconfactory.h"
#include "gtkiconhelperprivate.h"
#include "gtkicontheme.h"
#include "gtkinvisible.h"
#include "gtkmain.h"
#include "gtkplug.h"
-#include "gtkstock.h"
+#include "deprecated/gtkstock.h"
#include "gtktooltip.h"
#include "gtkwindow.h"
#include "gtkintl.h"
#include "gtkentry.h"
#include "gtkentrybuffer.h"
#include "gtkiconhelperprivate.h"
-#include "gtkimagemenuitem.h"
+#include "deprecated/gtkimagemenuitem.h"
#include "gtkimcontextsimple.h"
#include "gtkimmulticontext.h"
#include "gtkintl.h"
#include "gtkselection.h"
#include "gtksettings.h"
#include "gtkspinbutton.h"
-#include "gtkstock.h"
+#include "deprecated/gtkstock.h"
#include "gtktextutil.h"
#include "gtkwindow.h"
#include "gtktreeview.h"
#include "gtkentryprivate.h"
#include "gtkcelllayout.h"
#include "gtktooltip.h"
-#include "gtkiconfactory.h"
+#include "deprecated/gtkiconfactory.h"
#include "gtkicontheme.h"
#include "gtkwidgetprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkcombobox.h"
#include "gtkdnd.h"
#include "gtkicontheme.h"
-#include "gtkiconfactory.h"
+#include "deprecated/gtkiconfactory.h"
#include "gtkimage.h"
#include "gtklabel.h"
#include "gtkliststore.h"
-#include "gtkstock.h"
+#include "deprecated/gtkstock.h"
#include "gtktreemodelfilter.h"
#include "gtkseparator.h"
#include "gtkfilechooserdialog.h"
#include "gtkfilesystemmodel.h"
#include "gtkframe.h"
#include "gtkgrid.h"
-#include "gtkiconfactory.h"
+#include "deprecated/gtkiconfactory.h"
#include "gtkicontheme.h"
#include "gtkimage.h"
-#include "gtkimagemenuitem.h"
+#include "deprecated/gtkimagemenuitem.h"
#include "gtkinfobar.h"
#include "gtklabel.h"
#include "gtkmarshalers.h"
#include "gtkfontchooserwidget.h"
#include "gtkfontchooserutils.h"
#include "gtkbox.h"
-#include "gtkstock.h"
+#include "deprecated/gtkstock.h"
#include "gtkintl.h"
#include "gtkaccessible.h"
#include "gtkbuildable.h"
+++ /dev/null
-/* GTK - The GIMP Toolkit
- * Copyright (C) 2000 Red Hat, Inc.
- * 2008 Johan Dahlin
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#include "config.h"
-
-#define GDK_DISABLE_DEPRECATION_WARNINGS
-
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-
-#include "gtkiconfactory.h"
-#include "gtkiconcache.h"
-#include "gtkdebug.h"
-#include "gtkicontheme.h"
-#include "gtksettingsprivate.h"
-#include "gtkstock.h"
-#include "gtkwidget.h"
-#include "gtkintl.h"
-#include "gtkbuildable.h"
-#include "gtkbuilderprivate.h"
-#include "gtktypebuiltins.h"
-#include "deprecated/gtkstyle.h"
-
-/**
- * SECTION:gtkiconfactory
- * @Short_description: Manipulating stock icons
- * @Title: Themeable Stock Images
- *
- * Browse the available stock icons in the list of stock IDs found <link
- * linkend="gtk-Stock-Items">here</link>. You can also use
- * the <application>gtk-demo</application> application for this purpose.
- *
- * An icon factory manages a collection of #GtkIconSet; a #GtkIconSet manages a
- * set of variants of a particular icon (i.e. a #GtkIconSet contains variants for
- * different sizes and widget states). Icons in an icon factory are named by a
- * stock ID, which is a simple string identifying the icon. Each #GtkStyle has a
- * list of #GtkIconFactory derived from the current theme; those icon factories
- * are consulted first when searching for an icon. If the theme doesn't set a
- * particular icon, GTK+ looks for the icon in a list of default icon factories,
- * maintained by gtk_icon_factory_add_default() and
- * gtk_icon_factory_remove_default(). Applications with icons should add a default
- * icon factory with their icons, which will allow themes to override the icons
- * for the application.
- *
- * To display an icon, always use gtk_style_lookup_icon_set() on the widget that
- * will display the icon, or the convenience function
- * gtk_widget_render_icon(). These functions take the theme into account when
- * looking up the icon to use for a given stock ID.
- *
- * <refsect2 id="GtkIconFactory-BUILDER-UI">
- * <title>GtkIconFactory as GtkBuildable</title>
- * <para>
- * GtkIconFactory supports a custom <sources> element, which can contain
- * multiple <source> elements.
- * The following attributes are allowed:
- * <variablelist>
- * <varlistentry>
- * <term>stock-id</term>
- * <listitem><para>
- * The stock id of the source, a string.
- * This attribute is mandatory
- * </para></listitem>
- * </varlistentry>
- * <varlistentry>
- * <term>filename</term>
- * <listitem><para>
- * The filename of the source, a string.
- * This attribute is optional
- * </para></listitem>
- * </varlistentry>
- * <varlistentry>
- * <term>icon-name</term>
- * <listitem><para>
- * The icon name for the source, a string.
- * This attribute is optional.
- * </para></listitem>
- * </varlistentry>
- * <varlistentry>
- * <term>size</term>
- * <listitem><para>
- * Size of the icon, a #GtkIconSize enum value.
- * This attribute is optional.
- * </para></listitem>
- * </varlistentry>
- * <varlistentry>
- * <term>direction</term>
- * <listitem><para>
- * Direction of the source, a #GtkTextDirection enum value.
- * This attribute is optional.
- * </para></listitem>
- * </varlistentry>
- * <varlistentry>
- * <term>state</term>
- * <listitem><para>
- * State of the source, a #GtkStateType enum value.
- * This attribute is optional.
- * </para></listitem>
- * </varlistentry>
- * </variablelist>
- * <example>
- * <title>A #GtkIconFactory UI definition fragment.</title>
- * <programlisting><![CDATA[
- * <object class="GtkIconFactory" id="iconfactory1">
- * <sources>
- * <source stock-id="apple-red" filename="apple-red.png"/>
- * </sources>
- * </object>
- * <object class="GtkWindow" id="window1">
- * <child>
- * <object class="GtkButton" id="apple_button">
- * <property name="label">apple-red</property>
- * <property name="use-stock">True</property>
- * </object>
- * </child>
- * </object>
- * ]]>
- * </programlisting>
- * </example>
- * </para>
- * </refsect2>
- */
-
-
-static GSList *all_icon_factories = NULL;
-
-struct _GtkIconFactoryPrivate
-{
- GHashTable *icons;
-};
-
-typedef enum {
- GTK_ICON_SOURCE_EMPTY,
- GTK_ICON_SOURCE_ICON_NAME,
- GTK_ICON_SOURCE_STATIC_ICON_NAME,
- GTK_ICON_SOURCE_FILENAME,
- GTK_ICON_SOURCE_PIXBUF
-} GtkIconSourceType;
-
-struct _GtkIconSource
-{
- GtkIconSourceType type;
-
- union {
- gchar *icon_name;
- gchar *filename;
- GdkPixbuf *pixbuf;
- } source;
-
- GdkPixbuf *filename_pixbuf;
-
- GtkTextDirection direction;
- GtkStateType state;
- GtkIconSize size;
-
- /* If TRUE, then the parameter is wildcarded, and the above
- * fields should be ignored. If FALSE, the parameter is
- * specified, and the above fields should be valid.
- */
- guint any_direction : 1;
- guint any_state : 1;
- guint any_size : 1;
-};
-
-
-static void
-gtk_icon_factory_buildable_init (GtkBuildableIface *iface);
-
-static gboolean gtk_icon_factory_buildable_custom_tag_start (GtkBuildable *buildable,
- GtkBuilder *builder,
- GObject *child,
- const gchar *tagname,
- GMarkupParser *parser,
- gpointer *data);
-static void gtk_icon_factory_buildable_custom_tag_end (GtkBuildable *buildable,
- GtkBuilder *builder,
- GObject *child,
- const gchar *tagname,
- gpointer *user_data);
-static void gtk_icon_factory_finalize (GObject *object);
-static void get_default_icons (GtkIconFactory *icon_factory);
-static void icon_source_clear (GtkIconSource *source);
-
-static GtkIconSize icon_size_register_intern (const gchar *name,
- gint width,
- gint height);
-
-#define GTK_ICON_SOURCE_INIT(any_direction, any_state, any_size) \
- { GTK_ICON_SOURCE_EMPTY, { NULL }, NULL, \
- 0, 0, 0, \
- any_direction, any_state, any_size }
-
-G_DEFINE_TYPE_WITH_CODE (GtkIconFactory, gtk_icon_factory, G_TYPE_OBJECT,
- G_ADD_PRIVATE (GtkIconFactory)
- G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
- gtk_icon_factory_buildable_init))
-
-static void
-gtk_icon_factory_init (GtkIconFactory *factory)
-{
- GtkIconFactoryPrivate *priv;
-
- factory->priv = gtk_icon_factory_get_instance_private (factory);
- priv = factory->priv;
-
- priv->icons = g_hash_table_new (g_str_hash, g_str_equal);
- all_icon_factories = g_slist_prepend (all_icon_factories, factory);
-}
-
-static void
-gtk_icon_factory_class_init (GtkIconFactoryClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = gtk_icon_factory_finalize;
-}
-
-static void
-gtk_icon_factory_buildable_init (GtkBuildableIface *iface)
-{
- iface->custom_tag_start = gtk_icon_factory_buildable_custom_tag_start;
- iface->custom_tag_end = gtk_icon_factory_buildable_custom_tag_end;
-}
-
-static void
-free_icon_set (gpointer key, gpointer value, gpointer data)
-{
- g_free (key);
- gtk_icon_set_unref (value);
-}
-
-static void
-gtk_icon_factory_finalize (GObject *object)
-{
- GtkIconFactory *factory = GTK_ICON_FACTORY (object);
- GtkIconFactoryPrivate *priv = factory->priv;
-
- all_icon_factories = g_slist_remove (all_icon_factories, factory);
-
- g_hash_table_foreach (priv->icons, free_icon_set, NULL);
-
- g_hash_table_destroy (priv->icons);
-
- G_OBJECT_CLASS (gtk_icon_factory_parent_class)->finalize (object);
-}
-
-/**
- * gtk_icon_factory_new:
- *
- * Creates a new #GtkIconFactory. An icon factory manages a collection
- * of #GtkIconSet<!-- -->s; a #GtkIconSet manages a set of variants of a
- * particular icon (i.e. a #GtkIconSet contains variants for different
- * sizes and widget states). Icons in an icon factory are named by a
- * stock ID, which is a simple string identifying the icon. Each
- * #GtkStyle has a list of #GtkIconFactory<!-- -->s derived from the current
- * theme; those icon factories are consulted first when searching for
- * an icon. If the theme doesn't set a particular icon, GTK+ looks for
- * the icon in a list of default icon factories, maintained by
- * gtk_icon_factory_add_default() and
- * gtk_icon_factory_remove_default(). Applications with icons should
- * add a default icon factory with their icons, which will allow
- * themes to override the icons for the application.
- *
- * Return value: a new #GtkIconFactory
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-GtkIconFactory*
-gtk_icon_factory_new (void)
-{
- return g_object_new (GTK_TYPE_ICON_FACTORY, NULL);
-}
-
-/**
- * gtk_icon_factory_add:
- * @factory: a #GtkIconFactory
- * @stock_id: icon name
- * @icon_set: icon set
- *
- * Adds the given @icon_set to the icon factory, under the name
- * @stock_id. @stock_id should be namespaced for your application,
- * e.g. "myapp-whatever-icon". Normally applications create a
- * #GtkIconFactory, then add it to the list of default factories with
- * gtk_icon_factory_add_default(). Then they pass the @stock_id to
- * widgets such as #GtkImage to display the icon. Themes can provide
- * an icon with the same name (such as "myapp-whatever-icon") to
- * override your application's default icons. If an icon already
- * existed in @factory for @stock_id, it is unreferenced and replaced
- * with the new @icon_set.
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-void
-gtk_icon_factory_add (GtkIconFactory *factory,
- const gchar *stock_id,
- GtkIconSet *icon_set)
-{
- GtkIconFactoryPrivate *priv = factory->priv;
- gpointer old_key = NULL;
- gpointer old_value = NULL;
-
- g_return_if_fail (GTK_IS_ICON_FACTORY (factory));
- g_return_if_fail (stock_id != NULL);
- g_return_if_fail (icon_set != NULL);
-
- g_hash_table_lookup_extended (priv->icons, stock_id,
- &old_key, &old_value);
-
- if (old_value == icon_set)
- return;
-
- gtk_icon_set_ref (icon_set);
-
- /* GHashTable key memory management is so fantastically broken. */
- if (old_key)
- g_hash_table_insert (priv->icons, old_key, icon_set);
- else
- g_hash_table_insert (priv->icons, g_strdup (stock_id), icon_set);
-
- if (old_value)
- gtk_icon_set_unref (old_value);
-}
-
-/**
- * gtk_icon_factory_lookup:
- * @factory: a #GtkIconFactory
- * @stock_id: an icon name
- *
- * Looks up @stock_id in the icon factory, returning an icon set
- * if found, otherwise %NULL. For display to the user, you should
- * use gtk_style_lookup_icon_set() on the #GtkStyle for the
- * widget that will display the icon, instead of using this
- * function directly, so that themes are taken into account.
- *
- * Return value: (transfer none): icon set of @stock_id.
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-GtkIconSet *
-gtk_icon_factory_lookup (GtkIconFactory *factory,
- const gchar *stock_id)
-{
- GtkIconFactoryPrivate *priv;
-
- g_return_val_if_fail (GTK_IS_ICON_FACTORY (factory), NULL);
- g_return_val_if_fail (stock_id != NULL, NULL);
-
- priv = factory->priv;
-
- return g_hash_table_lookup (priv->icons, stock_id);
-}
-
-static GSList *default_factories = NULL;
-
-/**
- * gtk_icon_factory_add_default:
- * @factory: a #GtkIconFactory
- *
- * Adds an icon factory to the list of icon factories searched by
- * gtk_style_lookup_icon_set(). This means that, for example,
- * gtk_image_new_from_stock() will be able to find icons in @factory.
- * There will normally be an icon factory added for each library or
- * application that comes with icons. The default icon factories
- * can be overridden by themes.
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-void
-gtk_icon_factory_add_default (GtkIconFactory *factory)
-{
- g_return_if_fail (GTK_IS_ICON_FACTORY (factory));
-
- g_object_ref (factory);
-
- default_factories = g_slist_prepend (default_factories, factory);
-}
-
-/**
- * gtk_icon_factory_remove_default:
- * @factory: a #GtkIconFactory previously added with gtk_icon_factory_add_default()
- *
- * Removes an icon factory from the list of default icon
- * factories. Not normally used; you might use it for a library that
- * can be unloaded or shut down.
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-void
-gtk_icon_factory_remove_default (GtkIconFactory *factory)
-{
- g_return_if_fail (GTK_IS_ICON_FACTORY (factory));
-
- default_factories = g_slist_remove (default_factories, factory);
-
- g_object_unref (factory);
-}
-
-static GtkIconFactory *
-_gtk_icon_factory_get_default_icons (void)
-{
- static GtkIconFactory *default_icons = NULL;
- GtkIconFactory *icons = NULL;
- GdkScreen *screen = gdk_screen_get_default ();
-
- if (screen)
- icons = g_object_get_data (G_OBJECT (screen), "gtk-default-icons");
-
- if (icons == NULL)
- {
- if (default_icons == NULL)
- {
- default_icons = gtk_icon_factory_new ();
- get_default_icons (default_icons);
- }
- if (screen)
- g_object_set_data_full (G_OBJECT (screen),
- I_("gtk-default-icons"),
- default_icons,
- g_object_unref);
- icons = default_icons;
- }
-
- return icons;
-}
-
-/**
- * gtk_icon_factory_lookup_default:
- * @stock_id: an icon name
- *
- * Looks for an icon in the list of default icon factories. For
- * display to the user, you should use gtk_style_lookup_icon_set() on
- * the #GtkStyle for the widget that will display the icon, instead of
- * using this function directly, so that themes are taken into
- * account.
- *
- * Return value: (transfer none): a #GtkIconSet, or %NULL
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-GtkIconSet *
-gtk_icon_factory_lookup_default (const gchar *stock_id)
-{
- GSList *tmp_list;
- GtkIconFactory *default_icons;
-
- g_return_val_if_fail (stock_id != NULL, NULL);
-
- tmp_list = default_factories;
- while (tmp_list != NULL)
- {
- GtkIconSet *icon_set =
- gtk_icon_factory_lookup (GTK_ICON_FACTORY (tmp_list->data),
- stock_id);
-
- if (icon_set)
- return icon_set;
-
- tmp_list = g_slist_next (tmp_list);
- }
-
- default_icons = _gtk_icon_factory_get_default_icons ();
- if (default_icons)
- return gtk_icon_factory_lookup (default_icons, stock_id);
- else
- return NULL;
-}
-
-static void
-register_stock_icon (GtkIconFactory *factory,
- const gchar *stock_id,
- const gchar *icon_name)
-{
- GtkIconSet *set = gtk_icon_set_new ();
- GtkIconSource source = GTK_ICON_SOURCE_INIT (TRUE, TRUE, TRUE);
-
- source.type = GTK_ICON_SOURCE_STATIC_ICON_NAME;
- source.source.icon_name = (gchar *)icon_name;
- source.direction = GTK_TEXT_DIR_NONE;
- gtk_icon_set_add_source (set, &source);
-
- gtk_icon_factory_add (factory, stock_id, set);
- gtk_icon_set_unref (set);
-}
-
-static void
-register_bidi_stock_icon (GtkIconFactory *factory,
- const gchar *stock_id,
- const gchar *icon_name)
-{
- GtkIconSet *set = gtk_icon_set_new ();
- GtkIconSource source = GTK_ICON_SOURCE_INIT (FALSE, TRUE, TRUE);
-
- source.type = GTK_ICON_SOURCE_STATIC_ICON_NAME;
- source.source.icon_name = (gchar *)icon_name;
- source.direction = GTK_TEXT_DIR_LTR;
- gtk_icon_set_add_source (set, &source);
-
- source.type = GTK_ICON_SOURCE_STATIC_ICON_NAME;
- source.source.icon_name = (gchar *)icon_name;
- source.direction = GTK_TEXT_DIR_RTL;
- gtk_icon_set_add_source (set, &source);
-
- gtk_icon_factory_add (factory, stock_id, set);
- gtk_icon_set_unref (set);
-}
-
-static void
-get_default_icons (GtkIconFactory *factory)
-{
- /* KEEP IN SYNC with gtkstock.c */
-
- register_stock_icon (factory, GTK_STOCK_DIALOG_AUTHENTICATION, "dialog-password");
- register_stock_icon (factory, GTK_STOCK_DIALOG_ERROR, "dialog-error");
- register_stock_icon (factory, GTK_STOCK_DIALOG_INFO, "dialog-information");
- register_stock_icon (factory, GTK_STOCK_DIALOG_QUESTION, "dialog-question");
- register_stock_icon (factory, GTK_STOCK_DIALOG_WARNING, "dialog-warning");
- register_stock_icon (factory, GTK_STOCK_DND, GTK_STOCK_DND);
- register_stock_icon (factory, GTK_STOCK_DND_MULTIPLE, GTK_STOCK_DND_MULTIPLE);
- register_stock_icon (factory, GTK_STOCK_APPLY, GTK_STOCK_APPLY);
- register_stock_icon (factory, GTK_STOCK_CANCEL, GTK_STOCK_CANCEL);
- register_stock_icon (factory, GTK_STOCK_NO, GTK_STOCK_NO);
- register_stock_icon (factory, GTK_STOCK_OK, GTK_STOCK_OK);
- register_stock_icon (factory, GTK_STOCK_YES, GTK_STOCK_YES);
- register_stock_icon (factory, GTK_STOCK_CLOSE, "window-close");
- register_stock_icon (factory, GTK_STOCK_ADD, "list-add");
- register_stock_icon (factory, GTK_STOCK_JUSTIFY_CENTER, "format-justify-center");
- register_stock_icon (factory, GTK_STOCK_JUSTIFY_FILL, "format-justify-fill");
- register_stock_icon (factory, GTK_STOCK_JUSTIFY_LEFT, "format-justify-left");
- register_stock_icon (factory, GTK_STOCK_JUSTIFY_RIGHT, "format-justify-right");
- register_stock_icon (factory, GTK_STOCK_GOTO_BOTTOM, "go-bottom");
- register_stock_icon (factory, GTK_STOCK_CDROM, "media-optical");
- register_stock_icon (factory, GTK_STOCK_CONVERT, GTK_STOCK_CONVERT);
- register_stock_icon (factory, GTK_STOCK_COPY, "edit-copy");
- register_stock_icon (factory, GTK_STOCK_CUT, "edit-cut");
- register_stock_icon (factory, GTK_STOCK_GO_DOWN, "go-down");
- register_stock_icon (factory, GTK_STOCK_EXECUTE, "system-run");
- register_stock_icon (factory, GTK_STOCK_QUIT, "application-exit");
- register_bidi_stock_icon (factory, GTK_STOCK_GOTO_FIRST, "go-first");
- register_stock_icon (factory, GTK_STOCK_SELECT_FONT, GTK_STOCK_SELECT_FONT);
- register_stock_icon (factory, GTK_STOCK_FULLSCREEN, "view-fullscreen");
- register_stock_icon (factory, GTK_STOCK_LEAVE_FULLSCREEN, "view-restore");
- register_stock_icon (factory, GTK_STOCK_HARDDISK, "drive-harddisk");
- register_stock_icon (factory, GTK_STOCK_HELP, "help-contents");
- register_stock_icon (factory, GTK_STOCK_HOME, "go-home");
- register_stock_icon (factory, GTK_STOCK_INFO, "dialog-information");
- register_bidi_stock_icon (factory, GTK_STOCK_JUMP_TO, "go-jump");
- register_bidi_stock_icon (factory, GTK_STOCK_GOTO_LAST, "go-last");
- register_bidi_stock_icon (factory, GTK_STOCK_GO_BACK, "go-previous");
- register_stock_icon (factory, GTK_STOCK_MISSING_IMAGE, "image-missing");
- register_stock_icon (factory, GTK_STOCK_NETWORK, "network-idle");
- register_stock_icon (factory, GTK_STOCK_NEW, "document-new");
- register_stock_icon (factory, GTK_STOCK_OPEN, "document-open");
- register_stock_icon (factory, GTK_STOCK_ORIENTATION_PORTRAIT, GTK_STOCK_ORIENTATION_PORTRAIT);
- register_stock_icon (factory, GTK_STOCK_ORIENTATION_LANDSCAPE, GTK_STOCK_ORIENTATION_LANDSCAPE);
- register_stock_icon (factory, GTK_STOCK_ORIENTATION_REVERSE_PORTRAIT, GTK_STOCK_ORIENTATION_REVERSE_PORTRAIT);
- register_stock_icon (factory, GTK_STOCK_ORIENTATION_REVERSE_LANDSCAPE, GTK_STOCK_ORIENTATION_REVERSE_LANDSCAPE);
- register_stock_icon (factory, GTK_STOCK_PAGE_SETUP, GTK_STOCK_PAGE_SETUP);
- register_stock_icon (factory, GTK_STOCK_PASTE, "edit-paste");
- register_stock_icon (factory, GTK_STOCK_PREFERENCES, GTK_STOCK_PREFERENCES);
- register_stock_icon (factory, GTK_STOCK_PRINT, "document-print");
- register_stock_icon (factory, GTK_STOCK_PRINT_ERROR, "printer-error");
- register_stock_icon (factory, GTK_STOCK_PRINT_PAUSED, "printer-paused");
- register_stock_icon (factory, GTK_STOCK_PRINT_PREVIEW, "document-print-preview");
- register_stock_icon (factory, GTK_STOCK_PRINT_REPORT, "printer-info");
- register_stock_icon (factory, GTK_STOCK_PRINT_WARNING, "printer-warning");
- register_stock_icon (factory, GTK_STOCK_PROPERTIES, "document-properties");
- register_bidi_stock_icon (factory, GTK_STOCK_REDO, "edit-redo");
- register_stock_icon (factory, GTK_STOCK_REMOVE, "list-remove");
- register_stock_icon (factory, GTK_STOCK_REFRESH, "view-refresh");
- register_bidi_stock_icon (factory, GTK_STOCK_REVERT_TO_SAVED, "document-revert");
- register_bidi_stock_icon (factory, GTK_STOCK_GO_FORWARD, "go-next");
- register_stock_icon (factory, GTK_STOCK_SAVE, "document-save");
- register_stock_icon (factory, GTK_STOCK_FLOPPY, "media-floppy");
- register_stock_icon (factory, GTK_STOCK_SAVE_AS, "document-save-as");
- register_stock_icon (factory, GTK_STOCK_FIND, "edit-find");
- register_stock_icon (factory, GTK_STOCK_FIND_AND_REPLACE, "edit-find-replace");
- register_stock_icon (factory, GTK_STOCK_SORT_DESCENDING, "view-sort-descending");
- register_stock_icon (factory, GTK_STOCK_SORT_ASCENDING, "view-sort-ascending");
- register_stock_icon (factory, GTK_STOCK_SPELL_CHECK, "tools-check-spelling");
- register_stock_icon (factory, GTK_STOCK_STOP, "process-stop");
- register_stock_icon (factory, GTK_STOCK_BOLD, "format-text-bold");
- register_stock_icon (factory, GTK_STOCK_ITALIC, "format-text-italic");
- register_stock_icon (factory, GTK_STOCK_STRIKETHROUGH, "format-text-strikethrough");
- register_stock_icon (factory, GTK_STOCK_UNDERLINE, "format-text-underline");
- register_bidi_stock_icon (factory, GTK_STOCK_INDENT, "format-indent-more");
- register_bidi_stock_icon (factory, GTK_STOCK_UNINDENT, "format-indent-less");
- register_stock_icon (factory, GTK_STOCK_GOTO_TOP, "go-top");
- register_stock_icon (factory, GTK_STOCK_DELETE, "edit-delete");
- register_bidi_stock_icon (factory, GTK_STOCK_UNDELETE, GTK_STOCK_UNDELETE);
- register_bidi_stock_icon (factory, GTK_STOCK_UNDO, "edit-undo");
- register_stock_icon (factory, GTK_STOCK_GO_UP, "go-up");
- register_stock_icon (factory, GTK_STOCK_FILE, "text-x-generic");
- register_stock_icon (factory, GTK_STOCK_DIRECTORY, "folder");
- register_stock_icon (factory, GTK_STOCK_ABOUT, "help-about");
- register_stock_icon (factory, GTK_STOCK_CONNECT, GTK_STOCK_CONNECT);
- register_stock_icon (factory, GTK_STOCK_DISCONNECT, GTK_STOCK_DISCONNECT);
- register_stock_icon (factory, GTK_STOCK_EDIT, GTK_STOCK_EDIT);
- register_stock_icon (factory, GTK_STOCK_CAPS_LOCK_WARNING, GTK_STOCK_CAPS_LOCK_WARNING);
- register_bidi_stock_icon (factory, GTK_STOCK_MEDIA_FORWARD, "media-seek-forward");
- register_bidi_stock_icon (factory, GTK_STOCK_MEDIA_NEXT, "media-skip-forward");
- register_stock_icon (factory, GTK_STOCK_MEDIA_PAUSE, "media-playback-pause");
- register_bidi_stock_icon (factory, GTK_STOCK_MEDIA_PLAY, "media-playback-start");
- register_bidi_stock_icon (factory, GTK_STOCK_MEDIA_PREVIOUS, "media-skip-backward");
- register_stock_icon (factory, GTK_STOCK_MEDIA_RECORD, "media-record");
- register_bidi_stock_icon (factory, GTK_STOCK_MEDIA_REWIND, "media-seek-backward");
- register_stock_icon (factory, GTK_STOCK_MEDIA_STOP, "media-playback-stop");
- register_stock_icon (factory, GTK_STOCK_INDEX, GTK_STOCK_INDEX);
- register_stock_icon (factory, GTK_STOCK_ZOOM_100, "zoom-original");
- register_stock_icon (factory, GTK_STOCK_ZOOM_IN, "zoom-in");
- register_stock_icon (factory, GTK_STOCK_ZOOM_OUT, "zoom-out");
- register_stock_icon (factory, GTK_STOCK_ZOOM_FIT, "zoom-fit-best");
- register_stock_icon (factory, GTK_STOCK_SELECT_ALL, "edit-select-all");
- register_stock_icon (factory, GTK_STOCK_CLEAR, "edit-clear");
- register_stock_icon (factory, GTK_STOCK_SELECT_COLOR, GTK_STOCK_SELECT_COLOR);
- register_stock_icon (factory, GTK_STOCK_COLOR_PICKER, GTK_STOCK_COLOR_PICKER);
-}
-
-/************************************************************
- * Icon size handling *
- ************************************************************/
-
-typedef struct _IconSize IconSize;
-
-struct _IconSize
-{
- gint size;
- gchar *name;
-
- gint width;
- gint height;
-};
-
-typedef struct _IconAlias IconAlias;
-
-struct _IconAlias
-{
- gchar *name;
- gint target;
-};
-
-static GHashTable *icon_aliases = NULL;
-static IconSize *icon_sizes = NULL;
-static gint icon_sizes_allocated = 0;
-static gint icon_sizes_used = 0;
-
-static void
-init_icon_sizes (void)
-{
- if (icon_sizes == NULL)
- {
-#define NUM_BUILTIN_SIZES 7
- gint i;
-
- icon_aliases = g_hash_table_new (g_str_hash, g_str_equal);
-
- icon_sizes = g_new (IconSize, NUM_BUILTIN_SIZES);
- icon_sizes_allocated = NUM_BUILTIN_SIZES;
- icon_sizes_used = NUM_BUILTIN_SIZES;
-
- icon_sizes[GTK_ICON_SIZE_INVALID].size = 0;
- icon_sizes[GTK_ICON_SIZE_INVALID].name = NULL;
- icon_sizes[GTK_ICON_SIZE_INVALID].width = 0;
- icon_sizes[GTK_ICON_SIZE_INVALID].height = 0;
-
- /* the name strings aren't copied since we don't ever remove
- * icon sizes, so we don't need to know whether they're static.
- * Even if we did I suppose removing the builtin sizes would be
- * disallowed.
- */
-
- icon_sizes[GTK_ICON_SIZE_MENU].size = GTK_ICON_SIZE_MENU;
- icon_sizes[GTK_ICON_SIZE_MENU].name = "gtk-menu";
- icon_sizes[GTK_ICON_SIZE_MENU].width = 16;
- icon_sizes[GTK_ICON_SIZE_MENU].height = 16;
-
- icon_sizes[GTK_ICON_SIZE_BUTTON].size = GTK_ICON_SIZE_BUTTON;
- icon_sizes[GTK_ICON_SIZE_BUTTON].name = "gtk-button";
- icon_sizes[GTK_ICON_SIZE_BUTTON].width = 20;
- icon_sizes[GTK_ICON_SIZE_BUTTON].height = 20;
-
- icon_sizes[GTK_ICON_SIZE_SMALL_TOOLBAR].size = GTK_ICON_SIZE_SMALL_TOOLBAR;
- icon_sizes[GTK_ICON_SIZE_SMALL_TOOLBAR].name = "gtk-small-toolbar";
- icon_sizes[GTK_ICON_SIZE_SMALL_TOOLBAR].width = 18;
- icon_sizes[GTK_ICON_SIZE_SMALL_TOOLBAR].height = 18;
-
- icon_sizes[GTK_ICON_SIZE_LARGE_TOOLBAR].size = GTK_ICON_SIZE_LARGE_TOOLBAR;
- icon_sizes[GTK_ICON_SIZE_LARGE_TOOLBAR].name = "gtk-large-toolbar";
- icon_sizes[GTK_ICON_SIZE_LARGE_TOOLBAR].width = 24;
- icon_sizes[GTK_ICON_SIZE_LARGE_TOOLBAR].height = 24;
-
- icon_sizes[GTK_ICON_SIZE_DND].size = GTK_ICON_SIZE_DND;
- icon_sizes[GTK_ICON_SIZE_DND].name = "gtk-dnd";
- icon_sizes[GTK_ICON_SIZE_DND].width = 32;
- icon_sizes[GTK_ICON_SIZE_DND].height = 32;
-
- icon_sizes[GTK_ICON_SIZE_DIALOG].size = GTK_ICON_SIZE_DIALOG;
- icon_sizes[GTK_ICON_SIZE_DIALOG].name = "gtk-dialog";
- icon_sizes[GTK_ICON_SIZE_DIALOG].width = 48;
- icon_sizes[GTK_ICON_SIZE_DIALOG].height = 48;
-
- g_assert ((GTK_ICON_SIZE_DIALOG + 1) == NUM_BUILTIN_SIZES);
-
- /* Alias everything to itself. */
- i = 1; /* skip invalid size */
- while (i < NUM_BUILTIN_SIZES)
- {
- gtk_icon_size_register_alias (icon_sizes[i].name, icon_sizes[i].size);
-
- ++i;
- }
-
-#undef NUM_BUILTIN_SIZES
- }
-}
-
-static gboolean
-icon_size_lookup_intern (GtkIconSize size,
- gint *widthp,
- gint *heightp)
-{
- init_icon_sizes ();
-
- if (size == (GtkIconSize)-1)
- return FALSE;
-
- if (size >= icon_sizes_used)
- return FALSE;
-
- if (size == GTK_ICON_SIZE_INVALID)
- return FALSE;
-
- if (widthp)
- *widthp = icon_sizes[size].width;
-
- if (heightp)
- *heightp = icon_sizes[size].height;
-
- return TRUE;
-}
-
-/**
- * gtk_icon_size_lookup_for_settings:
- * @settings: a #GtkSettings object, used to determine
- * which set of user preferences to used.
- * @size: (type int): an icon size
- * @width: (out) (allow-none): location to store icon width
- * @height: (out) (allow-none): location to store icon height
- *
- * Obtains the pixel size of a semantic icon size, possibly
- * modified by user preferences for a particular
- * #GtkSettings. Normally @size would be
- * #GTK_ICON_SIZE_MENU, #GTK_ICON_SIZE_BUTTON, etc. This function
- * isn't normally needed, gtk_widget_render_icon_pixbuf() is the usual
- * way to get an icon for rendering, then just look at the size of
- * the rendered pixbuf. The rendered pixbuf may not even correspond to
- * the width/height returned by gtk_icon_size_lookup(), because themes
- * are free to render the pixbuf however they like, including changing
- * the usual size.
- *
- * Return value: %TRUE if @size was a valid size
- *
- * Since: 2.2
- *
- * Deprecated: 3.10: Use gtk_icon_size_lookup() instead.
- */
-gboolean
-gtk_icon_size_lookup_for_settings (GtkSettings *settings,
- GtkIconSize size,
- gint *width,
- gint *height)
-{
- g_return_val_if_fail (GTK_IS_SETTINGS (settings), FALSE);
-
- return icon_size_lookup_intern (size, width, height);
-}
-
-/**
- * gtk_icon_size_lookup:
- * @size: (type int): an icon size
- * @width: (out) (allow-none): location to store icon width
- * @height: (out) (allow-none): location to store icon height
- *
- * Obtains the pixel size of a semantic icon size @size:
- * #GTK_ICON_SIZE_MENU, #GTK_ICON_SIZE_BUTTON, etc. This function
- * isn't normally needed, gtk_icon_theme_load_icon() is the usual
- * way to get an icon for rendering, then just look at the size of
- * the rendered pixbuf. The rendered pixbuf may not even correspond to
- * the width/height returned by gtk_icon_size_lookup(), because themes
- * are free to render the pixbuf however they like, including changing
- * the usual size.
- *
- * Return value: %TRUE if @size was a valid size
- */
-gboolean
-gtk_icon_size_lookup (GtkIconSize size,
- gint *widthp,
- gint *heightp)
-{
- GTK_NOTE (MULTIHEAD,
- g_warning ("gtk_icon_size_lookup ()) is not multihead safe"));
-
- return icon_size_lookup_intern (size, widthp, heightp);
-}
-
-static GtkIconSize
-icon_size_register_intern (const gchar *name,
- gint width,
- gint height)
-{
- IconAlias *old_alias;
- GtkIconSize size;
-
- init_icon_sizes ();
-
- old_alias = g_hash_table_lookup (icon_aliases, name);
- if (old_alias && icon_sizes[old_alias->target].width > 0)
- {
- g_warning ("Icon size name '%s' already exists", name);
- return GTK_ICON_SIZE_INVALID;
- }
-
- if (old_alias)
- {
- size = old_alias->target;
- }
- else
- {
- if (icon_sizes_used == icon_sizes_allocated)
- {
- icon_sizes_allocated *= 2;
- icon_sizes = g_renew (IconSize, icon_sizes, icon_sizes_allocated);
- }
-
- size = icon_sizes_used++;
-
- /* alias to self. */
- gtk_icon_size_register_alias (name, size);
-
- icon_sizes[size].size = size;
- icon_sizes[size].name = g_strdup (name);
- }
-
- icon_sizes[size].width = width;
- icon_sizes[size].height = height;
-
- return size;
-}
-
-/**
- * gtk_icon_size_register:
- * @name: name of the icon size
- * @width: the icon width
- * @height: the icon height
- *
- * Registers a new icon size, along the same lines as #GTK_ICON_SIZE_MENU,
- * etc. Returns the integer value for the size.
- *
- * Returns: (type int): integer value representing the size
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-GtkIconSize
-gtk_icon_size_register (const gchar *name,
- gint width,
- gint height)
-{
- g_return_val_if_fail (name != NULL, 0);
- g_return_val_if_fail (width > 0, 0);
- g_return_val_if_fail (height > 0, 0);
-
- return icon_size_register_intern (name, width, height);
-}
-
-/**
- * gtk_icon_size_register_alias:
- * @alias: an alias for @target
- * @target: (type int): an existing icon size
- *
- * Registers @alias as another name for @target.
- * So calling gtk_icon_size_from_name() with @alias as argument
- * will return @target.
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-void
-gtk_icon_size_register_alias (const gchar *alias,
- GtkIconSize target)
-{
- IconAlias *ia;
-
- g_return_if_fail (alias != NULL);
-
- init_icon_sizes ();
-
- if (!icon_size_lookup_intern (target, NULL, NULL))
- g_warning ("gtk_icon_size_register_alias: Icon size %u does not exist", target);
-
- ia = g_hash_table_lookup (icon_aliases, alias);
- if (ia)
- {
- if (icon_sizes[ia->target].width > 0)
- {
- g_warning ("gtk_icon_size_register_alias: Icon size name '%s' already exists", alias);
- return;
- }
-
- ia->target = target;
- }
-
- if (!ia)
- {
- ia = g_new (IconAlias, 1);
- ia->name = g_strdup (alias);
- ia->target = target;
-
- g_hash_table_insert (icon_aliases, ia->name, ia);
- }
-}
-
-/**
- * gtk_icon_size_from_name:
- * @name: the name to look up.
- *
- * Looks up the icon size associated with @name.
- *
- * Return value: (type int): the icon size
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-GtkIconSize
-gtk_icon_size_from_name (const gchar *name)
-{
- IconAlias *ia;
-
- init_icon_sizes ();
-
- ia = g_hash_table_lookup (icon_aliases, name);
-
- if (ia && icon_sizes[ia->target].width > 0)
- return ia->target;
- else
- return GTK_ICON_SIZE_INVALID;
-}
-
-/**
- * gtk_icon_size_get_name:
- * @size: (type int): a #GtkIconSize.
- *
- * Gets the canonical name of the given icon size. The returned string
- * is statically allocated and should not be freed.
- *
- * Returns: the name of the given icon size.
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-const gchar*
-gtk_icon_size_get_name (GtkIconSize size)
-{
- if (size >= icon_sizes_used)
- return NULL;
- else
- return icon_sizes[size].name;
-}
-
-/************************************************************/
-
-/* Icon Set */
-
-
-static GdkPixbuf *find_in_cache (GtkIconSet *icon_set,
- GtkStyleContext *style_context,
- GtkTextDirection direction,
- GtkStateType state,
- GtkIconSize size,
- gint scale);
-static void add_to_cache (GtkIconSet *icon_set,
- GtkStyleContext *style_context,
- GtkTextDirection direction,
- GtkStateType state,
- GtkIconSize size,
- gint scale,
- GdkPixbuf *pixbuf);
-/* Clear icon set contents, drop references to all contained
- * GdkPixbuf objects and forget all GtkIconSources. Used to
- * recycle an icon set.
- */
-static void clear_cache (GtkIconSet *icon_set,
- gboolean style_detach);
-static GSList* copy_cache (GtkIconSet *icon_set,
- GtkIconSet *copy_recipient);
-static void attach_to_style (GtkIconSet *icon_set,
- GtkStyleContext *style_context);
-static void detach_from_style (GtkIconSet *icon_set,
- GtkStyleContext *style_context);
-static void style_dnotify (gpointer data);
-
-struct _GtkIconSet
-{
- guint ref_count;
-
- GSList *sources;
-
- /* Cache of the last few rendered versions of the icon. */
- GSList *cache;
-
- guint cache_size;
-
- guint cache_serial;
-};
-
-static guint cache_serial = 0;
-
-/**
- * gtk_icon_set_new:
- *
- * Creates a new #GtkIconSet. A #GtkIconSet represents a single icon
- * in various sizes and widget states. It can provide a #GdkPixbuf
- * for a given size and state on request, and automatically caches
- * some of the rendered #GdkPixbuf objects.
- *
- * Normally you would use gtk_widget_render_icon_pixbuf() instead of
- * using #GtkIconSet directly. The one case where you'd use
- * #GtkIconSet is to create application-specific icon sets to place in
- * a #GtkIconFactory.
- *
- * Return value: a new #GtkIconSet
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-GtkIconSet*
-gtk_icon_set_new (void)
-{
- GtkIconSet *icon_set;
-
- icon_set = g_new (GtkIconSet, 1);
-
- icon_set->ref_count = 1;
- icon_set->sources = NULL;
- icon_set->cache = NULL;
- icon_set->cache_size = 0;
- icon_set->cache_serial = cache_serial;
-
- return icon_set;
-}
-
-/**
- * gtk_icon_set_new_from_pixbuf:
- * @pixbuf: a #GdkPixbuf
- *
- * Creates a new #GtkIconSet with @pixbuf as the default/fallback
- * source image. If you don't add any additional #GtkIconSource to the
- * icon set, all variants of the icon will be created from @pixbuf,
- * using scaling, pixelation, etc. as required to adjust the icon size
- * or make the icon look insensitive/prelighted.
- *
- * Return value: a new #GtkIconSet
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-GtkIconSet *
-gtk_icon_set_new_from_pixbuf (GdkPixbuf *pixbuf)
-{
- GtkIconSet *set;
-
- GtkIconSource source = GTK_ICON_SOURCE_INIT (TRUE, TRUE, TRUE);
-
- g_return_val_if_fail (pixbuf != NULL, NULL);
-
- set = gtk_icon_set_new ();
-
- gtk_icon_source_set_pixbuf (&source, pixbuf);
- gtk_icon_set_add_source (set, &source);
- gtk_icon_source_set_pixbuf (&source, NULL);
-
- return set;
-}
-
-
-/**
- * gtk_icon_set_ref:
- * @icon_set: a #GtkIconSet.
- *
- * Increments the reference count on @icon_set.
- *
- * Return value: @icon_set.
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-GtkIconSet*
-gtk_icon_set_ref (GtkIconSet *icon_set)
-{
- g_return_val_if_fail (icon_set != NULL, NULL);
- g_return_val_if_fail (icon_set->ref_count > 0, NULL);
-
- icon_set->ref_count += 1;
-
- return icon_set;
-}
-
-/**
- * gtk_icon_set_unref:
- * @icon_set: a #GtkIconSet
- *
- * Decrements the reference count on @icon_set, and frees memory
- * if the reference count reaches 0.
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-void
-gtk_icon_set_unref (GtkIconSet *icon_set)
-{
- g_return_if_fail (icon_set != NULL);
- g_return_if_fail (icon_set->ref_count > 0);
-
- icon_set->ref_count -= 1;
-
- if (icon_set->ref_count == 0)
- {
- GSList *tmp_list = icon_set->sources;
- while (tmp_list != NULL)
- {
- gtk_icon_source_free (tmp_list->data);
-
- tmp_list = g_slist_next (tmp_list);
- }
- g_slist_free (icon_set->sources);
-
- clear_cache (icon_set, TRUE);
-
- g_free (icon_set);
- }
-}
-
-G_DEFINE_BOXED_TYPE (GtkIconSet, gtk_icon_set,
- gtk_icon_set_ref,
- gtk_icon_set_unref)
-
-/**
- * gtk_icon_set_copy:
- * @icon_set: a #GtkIconSet
- *
- * Copies @icon_set by value.
- *
- * Return value: a new #GtkIconSet identical to the first.
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- **/
-GtkIconSet*
-gtk_icon_set_copy (GtkIconSet *icon_set)
-{
- GtkIconSet *copy;
- GSList *tmp_list;
-
- copy = gtk_icon_set_new ();
-
- tmp_list = icon_set->sources;
- while (tmp_list != NULL)
- {
- copy->sources = g_slist_prepend (copy->sources,
- gtk_icon_source_copy (tmp_list->data));
-
- tmp_list = g_slist_next (tmp_list);
- }
-
- copy->sources = g_slist_reverse (copy->sources);
-
- copy->cache = copy_cache (icon_set, copy);
- copy->cache_size = icon_set->cache_size;
- copy->cache_serial = icon_set->cache_serial;
-
- return copy;
-}
-
-static gboolean
-sizes_equivalent (GtkIconSize lhs,
- GtkIconSize rhs)
-{
- /* We used to consider sizes equivalent if they were
- * the same pixel size, but we don't have the GtkSettings
- * here, so we can't do that. Plus, it's not clear that
- * it is right... it was just a workaround for the fact
- * that we register icons by logical size, not pixel size.
- */
-#if 1
- return lhs == rhs;
-#else
-
- gint r_w, r_h, l_w, l_h;
-
- icon_size_lookup_intern (rhs, &r_w, &r_h);
- icon_size_lookup_intern (lhs, &l_w, &l_h);
-
- return r_w == l_w && r_h == l_h;
-#endif
-}
-
-static GtkIconSource *
-find_best_matching_source (GtkIconSet *icon_set,
- GtkTextDirection direction,
- GtkStateType state,
- GtkIconSize size,
- GSList *failed)
-{
- GtkIconSource *source;
- GSList *tmp_list;
-
- /* We need to find the best icon source. Direction matters more
- * than state, state matters more than size. icon_set->sources
- * is sorted according to wildness, so if we take the first
- * match we find it will be the least-wild match (if there are
- * multiple matches for a given "wildness" then the RC file contained
- * dumb stuff, and we end up with an arbitrary matching source)
- */
-
- source = NULL;
- tmp_list = icon_set->sources;
- while (tmp_list != NULL)
- {
- GtkIconSource *s = tmp_list->data;
-
- if ((s->any_direction || (s->direction == direction)) &&
- (s->any_state || (s->state == state)) &&
- (s->any_size || size == (GtkIconSize)-1 || (sizes_equivalent (size, s->size))))
- {
- if (!g_slist_find (failed, s))
- {
- source = s;
- break;
- }
- }
-
- tmp_list = g_slist_next (tmp_list);
- }
-
- return source;
-}
-
-static gboolean
-ensure_filename_pixbuf (GtkIconSet *icon_set,
- GtkIconSource *source)
-{
- if (source->filename_pixbuf == NULL)
- {
- GError *error = NULL;
-
- source->filename_pixbuf = gdk_pixbuf_new_from_file (source->source.filename, &error);
-
- if (source->filename_pixbuf == NULL)
- {
- /* Remove this icon source so we don't keep trying to
- * load it.
- */
- g_warning ("Error loading icon: %s", error->message);
- g_error_free (error);
-
- icon_set->sources = g_slist_remove (icon_set->sources, source);
-
- gtk_icon_source_free (source);
-
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-static GdkPixbuf *
-render_icon_name_pixbuf (GtkIconSource *icon_source,
- GtkStyleContext *context,
- GtkIconSize size,
- gint scale)
-{
- GdkPixbuf *pixbuf;
- GdkPixbuf *tmp_pixbuf;
- GtkIconSource tmp_source;
- GdkScreen *screen;
- GtkIconTheme *icon_theme;
- GtkSettings *settings;
- gint width, height, pixel_size;
- gint *sizes, *s, dist;
- GError *error = NULL;
-
- screen = gtk_style_context_get_screen (context);
- icon_theme = gtk_icon_theme_get_for_screen (screen);
- settings = gtk_settings_get_for_screen (screen);
-
- if (!gtk_icon_size_lookup_for_settings (settings, size, &width, &height))
- {
- if (size == (GtkIconSize)-1)
- {
- /* Find an available size close to 48 */
- sizes = gtk_icon_theme_get_icon_sizes (icon_theme, icon_source->source.icon_name);
- dist = 1000;
- width = height = 48;
- for (s = sizes; *s; s++)
- {
- if (*s == -1)
- {
- width = height = 48;
- break;
- }
- if (*s < 48)
- {
- if (48 - *s < dist)
- {
- width = height = *s;
- dist = 48 - *s;
- }
- }
- else
- {
- if (*s - 48 < dist)
- {
- width = height = *s;
- dist = *s - 48;
- }
- }
- }
-
- g_free (sizes);
- }
- else
- {
- g_warning ("Invalid icon size %u\n", size);
- width = height = 24;
- }
- }
-
- pixel_size = MIN (width, height);
-
- if (icon_source->direction != GTK_TEXT_DIR_NONE)
- {
- gchar *suffix[3] = { NULL, "-ltr", "-rtl" };
- gchar *names[3];
- GtkIconInfo *info;
-
- names[0] = g_strconcat (icon_source->source.icon_name, suffix[icon_source->direction], NULL);
- names[1] = icon_source->source.icon_name;
- names[2] = NULL;
-
- info = gtk_icon_theme_choose_icon_for_scale (icon_theme,
- (const char **) names,
- pixel_size, scale,
- GTK_ICON_LOOKUP_USE_BUILTIN);
- g_free (names[0]);
- if (info)
- {
- tmp_pixbuf = gtk_icon_info_load_icon (info, &error);
- g_object_unref (info);
- }
- else
- tmp_pixbuf = NULL;
- }
- else
- {
- tmp_pixbuf = gtk_icon_theme_load_icon_for_scale (icon_theme,
- icon_source->source.icon_name,
- pixel_size, scale, 0,
- &error);
- }
-
- if (!tmp_pixbuf)
- {
- g_warning ("Error loading theme icon '%s' for stock: %s",
- icon_source->source.icon_name, error ? error->message : "");
- if (error)
- g_error_free (error);
- return NULL;
- }
-
- tmp_source = *icon_source;
- tmp_source.type = GTK_ICON_SOURCE_PIXBUF;
- tmp_source.source.pixbuf = tmp_pixbuf;
-
- pixbuf = gtk_render_icon_pixbuf (context, &tmp_source, -1);
-
- if (!pixbuf)
- g_warning ("Failed to render icon");
-
- g_object_unref (tmp_pixbuf);
-
- return pixbuf;
-}
-
-static GdkPixbuf *
-find_and_render_icon_source (GtkIconSet *icon_set,
- GtkStyleContext *context,
- GtkTextDirection direction,
- GtkStateType state,
- GtkIconSize size,
- gint scale)
-{
- GSList *failed = NULL;
- GdkPixbuf *pixbuf = NULL;
-
- /* We treat failure in two different ways:
- *
- * A) If loading a source that specifies a filename fails,
- * we treat that as permanent, and remove the source
- * from the GtkIconSet. (in ensure_filename_pixbuf ()
- * B) If loading a themed icon fails, or scaling an icon
- * fails, we treat that as transient and will try
- * again next time the icon falls out of the cache
- * and we need to recreate it.
- */
- while (pixbuf == NULL)
- {
- GtkIconSource *source = find_best_matching_source (icon_set, direction, state, size, failed);
-
- if (source == NULL)
- break;
-
- switch (source->type)
- {
- case GTK_ICON_SOURCE_FILENAME:
- if (!ensure_filename_pixbuf (icon_set, source))
- break;
- /* Fall through */
- case GTK_ICON_SOURCE_PIXBUF:
- pixbuf = gtk_render_icon_pixbuf (context, source, size);
- if (!pixbuf)
- {
- g_warning ("Failed to render icon");
- failed = g_slist_prepend (failed, source);
- }
-
- if (scale != 1)
- {
- GdkPixbuf *tmp = pixbuf;
- pixbuf = gdk_pixbuf_scale_simple (pixbuf,
- gdk_pixbuf_get_width (pixbuf) * scale,
- gdk_pixbuf_get_height (pixbuf) * scale,
- GDK_INTERP_BILINEAR);
- g_object_unref (tmp);
- }
- break;
- case GTK_ICON_SOURCE_ICON_NAME:
- case GTK_ICON_SOURCE_STATIC_ICON_NAME:
- pixbuf = render_icon_name_pixbuf (source, context,
- size, scale);
- if (!pixbuf)
- failed = g_slist_prepend (failed, source);
- break;
- case GTK_ICON_SOURCE_EMPTY:
- g_assert_not_reached ();
- }
- }
-
- g_slist_free (failed);
-
- return pixbuf;
-}
-
-extern GtkIconCache *_builtin_cache;
-
-static GdkPixbuf*
-render_fallback_image (GtkStyleContext *context,
- GtkTextDirection direction,
- GtkStateType state,
- GtkIconSize size)
-{
- /* This icon can be used for any direction/state/size */
- static GtkIconSource fallback_source = GTK_ICON_SOURCE_INIT (TRUE, TRUE, TRUE);
-
- if (fallback_source.type == GTK_ICON_SOURCE_EMPTY)
- {
- gint index;
- GdkPixbuf *pixbuf;
-
- _gtk_icon_theme_ensure_builtin_cache ();
-
- index = _gtk_icon_cache_get_directory_index (_builtin_cache, "24");
- pixbuf = _gtk_icon_cache_get_icon (_builtin_cache, "image-missing", index);
-
- g_return_val_if_fail(pixbuf != NULL, NULL);
-
- gtk_icon_source_set_pixbuf (&fallback_source, pixbuf);
- g_object_unref (pixbuf);
- }
-
- return gtk_render_icon_pixbuf (context, &fallback_source, size);
-}
-
-static GdkPixbuf*
-gtk_icon_set_render_icon_pixbuf_for_scale (GtkIconSet *icon_set,
- GtkStyleContext *context,
- GtkIconSize size,
- gint scale)
-{
- GdkPixbuf *icon = NULL;
- GtkStateFlags flags = 0;
- GtkStateType state;
- GtkTextDirection direction;
-
- g_return_val_if_fail (icon_set != NULL, NULL);
- g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
-
- flags = gtk_style_context_get_state (context);
- if (flags & GTK_STATE_FLAG_INSENSITIVE)
- state = GTK_STATE_INSENSITIVE;
- else if (flags & GTK_STATE_FLAG_PRELIGHT)
- state = GTK_STATE_PRELIGHT;
- else
- state = GTK_STATE_NORMAL;
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- direction = gtk_style_context_get_direction (context);
-G_GNUC_END_IGNORE_DEPRECATIONS;
-
- if (icon_set->sources)
- {
- icon = find_in_cache (icon_set, context, direction, state, size, scale);
- if (icon)
- return g_object_ref (icon);
- }
-
- if (icon_set->sources)
- icon = find_and_render_icon_source (icon_set, context, direction, state,
- size, scale);
-
- if (icon == NULL)
- icon = render_fallback_image (context, direction, state, size);
-
- add_to_cache (icon_set, context, direction, state, size, scale, icon);
-
- return icon;
-}
-
-/**
- * gtk_icon_set_render_icon_pixbuf:
- * @icon_set: a #GtkIconSet
- * @context: a #GtkStyleContext
- * @size: (type int): icon size. A size of (GtkIconSize)-1
- * means render at the size of the source and don't scale.
- *
- * Renders an icon using gtk_render_icon_pixbuf(). In most cases,
- * gtk_widget_render_icon_pixbuf() is better, since it automatically provides
- * most of the arguments from the current widget settings. This
- * function never returns %NULL; if the icon can't be rendered
- * (perhaps because an image file fails to load), a default "missing
- * image" icon will be returned instead.
- *
- * Return value: (transfer full): a #GdkPixbuf to be displayed
- *
- * Since: 3.0
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-GdkPixbuf *
-gtk_icon_set_render_icon_pixbuf (GtkIconSet *icon_set,
- GtkStyleContext *context,
- GtkIconSize size)
-{
- g_return_val_if_fail (icon_set != NULL, NULL);
- g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
-
- return gtk_icon_set_render_icon_pixbuf_for_scale (icon_set, context, size, 1);
-}
-
-/**
- * gtk_icon_set_render_icon_surface:
- * @icon_set: a #GtkIconSet
- * @context: a #GtkStyleContext
- * @size: (type int): icon size. A size of (GtkIconSize)-1
- * means render at the size of the source and don't scale.
- * @scale: the window scale to render for
- * @for_window: (allow-none): #GdkWindow to optimize drawing for, or %NULL
- *
- * Renders an icon using gtk_render_icon_pixbuf() and converts it to a
- * cairo surface.
- *
- * This function never returns %NULL; if the icon can't be rendered
- * (perhaps because an image file fails to load), a default "missing
- * image" icon will be returned instead.
- *
- * Return value: (transfer full): a #cairo_surface_t to be displayed
- *
- * Since: 3.10
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-cairo_surface_t *
-gtk_icon_set_render_icon_surface (GtkIconSet *icon_set,
- GtkStyleContext *context,
- GtkIconSize size,
- gint scale,
- GdkWindow *for_window)
-{
- GdkPixbuf *pixbuf;
- cairo_surface_t *surface;
-
- pixbuf = gtk_icon_set_render_icon_pixbuf_for_scale (icon_set, context, size, scale);
-
- surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, scale, for_window);
- g_object_unref (pixbuf);
-
- return surface;
-}
-
-/**
- * gtk_icon_set_render_icon:
- * @icon_set: a #GtkIconSet
- * @style: (allow-none): a #GtkStyle associated with @widget, or %NULL
- * @direction: text direction
- * @state: widget state
- * @size: (type int): icon size. A size of (GtkIconSize)-1
- * means render at the size of the source and don't scale.
- * @widget: (allow-none): widget that will display the icon, or %NULL.
- * The only use that is typically made of this
- * is to determine the appropriate #GdkScreen.
- * @detail: (allow-none): detail to pass to the theme engine, or %NULL.
- * Note that passing a detail of anything but %NULL
- * will disable caching.
- *
- * Renders an icon using gtk_style_render_icon(). In most cases,
- * gtk_widget_render_icon() is better, since it automatically provides
- * most of the arguments from the current widget settings. This
- * function never returns %NULL; if the icon can't be rendered
- * (perhaps because an image file fails to load), a default "missing
- * image" icon will be returned instead.
- *
- * Return value: (transfer full): a #GdkPixbuf to be displayed
- *
- * Deprecated: 3.0: Use gtk_icon_set_render_icon_pixbuf() instead
- */
-GdkPixbuf*
-gtk_icon_set_render_icon (GtkIconSet *icon_set,
- GtkStyle *style,
- GtkTextDirection direction,
- GtkStateType state,
- GtkIconSize size,
- GtkWidget *widget,
- const char *detail)
-{
- GdkPixbuf *icon;
- GtkStyleContext *context = NULL;
- GtkStateFlags flags = 0;
-
- g_return_val_if_fail (icon_set != NULL, NULL);
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-
- g_return_val_if_fail (style == NULL || GTK_IS_STYLE (style), NULL);
-
- if (style && gtk_style_has_context (style))
- {
- g_object_get (style, "context", &context, NULL);
- /* g_object_get returns a refed object */
- if (context)
- g_object_unref (context);
- }
- else if (widget)
- {
- context = gtk_widget_get_style_context (widget);
- }
-
- if (!context)
- return render_fallback_image (context, direction, state, size);
-
- gtk_style_context_save (context);
-
- switch (state)
- {
- case GTK_STATE_PRELIGHT:
- flags |= GTK_STATE_FLAG_PRELIGHT;
- break;
- case GTK_STATE_INSENSITIVE:
- flags |= GTK_STATE_FLAG_INSENSITIVE;
- break;
- default:
- break;
- }
-
- gtk_style_context_set_state (context, flags);
- gtk_style_context_set_direction (context, direction);
-
-G_GNUC_END_IGNORE_DEPRECATIONS;
-
- icon = gtk_icon_set_render_icon_pixbuf (icon_set, context, size);
-
- gtk_style_context_restore (context);
-
- return icon;
-}
-
-/* Order sources by their "wildness", so that "wilder" sources are
- * greater than "specific" sources; for determining ordering,
- * direction beats state beats size.
- */
-
-static int
-icon_source_compare (gconstpointer ap, gconstpointer bp)
-{
- const GtkIconSource *a = ap;
- const GtkIconSource *b = bp;
-
- if (!a->any_direction && b->any_direction)
- return -1;
- else if (a->any_direction && !b->any_direction)
- return 1;
- else if (!a->any_state && b->any_state)
- return -1;
- else if (a->any_state && !b->any_state)
- return 1;
- else if (!a->any_size && b->any_size)
- return -1;
- else if (a->any_size && !b->any_size)
- return 1;
- else
- return 0;
-}
-
-/**
- * gtk_icon_set_add_source:
- * @icon_set: a #GtkIconSet
- * @source: a #GtkIconSource
- *
- * Icon sets have a list of #GtkIconSource, which they use as base
- * icons for rendering icons in different states and sizes. Icons are
- * scaled, made to look insensitive, etc. in
- * gtk_icon_set_render_icon(), but #GtkIconSet needs base images to
- * work with. The base images and when to use them are described by
- * a #GtkIconSource.
- *
- * This function copies @source, so you can reuse the same source immediately
- * without affecting the icon set.
- *
- * An example of when you'd use this function: a web browser's "Back
- * to Previous Page" icon might point in a different direction in
- * Hebrew and in English; it might look different when insensitive;
- * and it might change size depending on toolbar mode (small/large
- * icons). So a single icon set would contain all those variants of
- * the icon, and you might add a separate source for each one.
- *
- * You should nearly always add a "default" icon source with all
- * fields wildcarded, which will be used as a fallback if no more
- * specific source matches. #GtkIconSet always prefers more specific
- * icon sources to more generic icon sources. The order in which you
- * add the sources to the icon set does not matter.
- *
- * gtk_icon_set_new_from_pixbuf() creates a new icon set with a
- * default icon source based on the given pixbuf.
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-void
-gtk_icon_set_add_source (GtkIconSet *icon_set,
- const GtkIconSource *source)
-{
- g_return_if_fail (icon_set != NULL);
- g_return_if_fail (source != NULL);
-
- if (source->type == GTK_ICON_SOURCE_EMPTY)
- {
- g_warning ("Useless empty GtkIconSource");
- return;
- }
-
- icon_set->sources = g_slist_insert_sorted (icon_set->sources,
- gtk_icon_source_copy (source),
- icon_source_compare);
-}
-
-/**
- * gtk_icon_set_get_sizes:
- * @icon_set: a #GtkIconSet
- * @sizes: (array length=n_sizes) (out) (type int): return location
- * for array of sizes
- * @n_sizes: location to store number of elements in returned array
- *
- * Obtains a list of icon sizes this icon set can render. The returned
- * array must be freed with g_free().
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-void
-gtk_icon_set_get_sizes (GtkIconSet *icon_set,
- GtkIconSize **sizes,
- gint *n_sizes)
-{
- GSList *tmp_list;
- gboolean all_sizes = FALSE;
- GSList *specifics = NULL;
-
- g_return_if_fail (icon_set != NULL);
- g_return_if_fail (sizes != NULL);
- g_return_if_fail (n_sizes != NULL);
-
- tmp_list = icon_set->sources;
- while (tmp_list != NULL)
- {
- GtkIconSource *source;
-
- source = tmp_list->data;
-
- if (source->any_size)
- {
- all_sizes = TRUE;
- break;
- }
- else
- specifics = g_slist_prepend (specifics, GINT_TO_POINTER (source->size));
-
- tmp_list = g_slist_next (tmp_list);
- }
-
- if (all_sizes)
- {
- /* Need to find out what sizes exist */
- gint i;
-
- init_icon_sizes ();
-
- *sizes = g_new (GtkIconSize, icon_sizes_used);
- *n_sizes = icon_sizes_used - 1;
-
- i = 1;
- while (i < icon_sizes_used)
- {
- (*sizes)[i - 1] = icon_sizes[i].size;
- ++i;
- }
- }
- else
- {
- gint i;
-
- *n_sizes = g_slist_length (specifics);
- *sizes = g_new (GtkIconSize, *n_sizes);
-
- i = 0;
- tmp_list = specifics;
- while (tmp_list != NULL)
- {
- (*sizes)[i] = GPOINTER_TO_INT (tmp_list->data);
-
- ++i;
- tmp_list = g_slist_next (tmp_list);
- }
- }
-
- g_slist_free (specifics);
-}
-
-
-/**
- * gtk_icon_source_new:
- *
- * Creates a new #GtkIconSource. A #GtkIconSource contains a #GdkPixbuf (or
- * image filename) that serves as the base image for one or more of the
- * icons in a #GtkIconSet, along with a specification for which icons in the
- * icon set will be based on that pixbuf or image file. An icon set contains
- * a set of icons that represent "the same" logical concept in different states,
- * different global text directions, and different sizes.
- *
- * So for example a web browser's "Back to Previous Page" icon might
- * point in a different direction in Hebrew and in English; it might
- * look different when insensitive; and it might change size depending
- * on toolbar mode (small/large icons). So a single icon set would
- * contain all those variants of the icon. #GtkIconSet contains a list
- * of #GtkIconSource from which it can derive specific icon variants in
- * the set.
- *
- * In the simplest case, #GtkIconSet contains one source pixbuf from
- * which it derives all variants. The convenience function
- * gtk_icon_set_new_from_pixbuf() handles this case; if you only have
- * one source pixbuf, just use that function.
- *
- * If you want to use a different base pixbuf for different icon
- * variants, you create multiple icon sources, mark which variants
- * they'll be used to create, and add them to the icon set with
- * gtk_icon_set_add_source().
- *
- * By default, the icon source has all parameters wildcarded. That is,
- * the icon source will be used as the base icon for any desired text
- * direction, widget state, or icon size.
- *
- * Return value: a new #GtkIconSource
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-GtkIconSource*
-gtk_icon_source_new (void)
-{
- GtkIconSource *src;
-
- src = g_new0 (GtkIconSource, 1);
-
- src->direction = GTK_TEXT_DIR_NONE;
- src->size = GTK_ICON_SIZE_INVALID;
- src->state = GTK_STATE_NORMAL;
-
- src->any_direction = TRUE;
- src->any_state = TRUE;
- src->any_size = TRUE;
-
- return src;
-}
-
-/**
- * gtk_icon_source_copy:
- * @source: a #GtkIconSource
- *
- * Creates a copy of @source; mostly useful for language bindings.
- *
- * Return value: a new #GtkIconSource
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-GtkIconSource*
-gtk_icon_source_copy (const GtkIconSource *source)
-{
- GtkIconSource *copy;
-
- g_return_val_if_fail (source != NULL, NULL);
-
- copy = g_new (GtkIconSource, 1);
-
- *copy = *source;
-
- switch (copy->type)
- {
- case GTK_ICON_SOURCE_EMPTY:
- case GTK_ICON_SOURCE_STATIC_ICON_NAME:
- break;
- case GTK_ICON_SOURCE_ICON_NAME:
- copy->source.icon_name = g_strdup (copy->source.icon_name);
- break;
- case GTK_ICON_SOURCE_FILENAME:
- copy->source.filename = g_strdup (copy->source.filename);
- if (copy->filename_pixbuf)
- g_object_ref (copy->filename_pixbuf);
- break;
- case GTK_ICON_SOURCE_PIXBUF:
- g_object_ref (copy->source.pixbuf);
- break;
- default:
- g_assert_not_reached();
- }
-
- return copy;
-}
-
-/**
- * gtk_icon_source_free:
- * @source: a #GtkIconSource
- *
- * Frees a dynamically-allocated icon source, along with its
- * filename, size, and pixbuf fields if those are not %NULL.
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-void
-gtk_icon_source_free (GtkIconSource *source)
-{
- g_return_if_fail (source != NULL);
-
- icon_source_clear (source);
- g_free (source);
-}
-
-G_DEFINE_BOXED_TYPE (GtkIconSource, gtk_icon_source,
- gtk_icon_source_copy,
- gtk_icon_source_free)
-
-static void
-icon_source_clear (GtkIconSource *source)
-{
- switch (source->type)
- {
- case GTK_ICON_SOURCE_EMPTY:
- break;
- case GTK_ICON_SOURCE_ICON_NAME:
- g_free (source->source.icon_name);
- /* fall thru */
- case GTK_ICON_SOURCE_STATIC_ICON_NAME:
- source->source.icon_name = NULL;
- break;
- case GTK_ICON_SOURCE_FILENAME:
- g_free (source->source.filename);
- source->source.filename = NULL;
- if (source->filename_pixbuf)
- g_object_unref (source->filename_pixbuf);
- source->filename_pixbuf = NULL;
- break;
- case GTK_ICON_SOURCE_PIXBUF:
- g_object_unref (source->source.pixbuf);
- source->source.pixbuf = NULL;
- break;
- default:
- g_assert_not_reached();
- }
-
- source->type = GTK_ICON_SOURCE_EMPTY;
-}
-
-/**
- * gtk_icon_source_set_filename:
- * @source: a #GtkIconSource
- * @filename: (type filename): image file to use
- *
- * Sets the name of an image file to use as a base image when creating
- * icon variants for #GtkIconSet. The filename must be absolute.
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-void
-gtk_icon_source_set_filename (GtkIconSource *source,
- const gchar *filename)
-{
- g_return_if_fail (source != NULL);
- g_return_if_fail (filename == NULL || g_path_is_absolute (filename));
-
- if (source->type == GTK_ICON_SOURCE_FILENAME &&
- source->source.filename == filename)
- return;
-
- icon_source_clear (source);
-
- if (filename != NULL)
- {
- source->type = GTK_ICON_SOURCE_FILENAME;
- source->source.filename = g_strdup (filename);
- }
-}
-
-/**
- * gtk_icon_source_set_icon_name:
- * @source: a #GtkIconSource
- * @icon_name: (allow-none): name of icon to use
- *
- * Sets the name of an icon to look up in the current icon theme
- * to use as a base image when creating icon variants for #GtkIconSet.
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-void
-gtk_icon_source_set_icon_name (GtkIconSource *source,
- const gchar *icon_name)
-{
- g_return_if_fail (source != NULL);
-
- if (source->type == GTK_ICON_SOURCE_ICON_NAME &&
- source->source.icon_name == icon_name)
- return;
-
- icon_source_clear (source);
-
- if (icon_name != NULL)
- {
- source->type = GTK_ICON_SOURCE_ICON_NAME;
- source->source.icon_name = g_strdup (icon_name);
- }
-}
-
-/**
- * gtk_icon_source_set_pixbuf:
- * @source: a #GtkIconSource
- * @pixbuf: pixbuf to use as a source
- *
- * Sets a pixbuf to use as a base image when creating icon variants
- * for #GtkIconSet.
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-void
-gtk_icon_source_set_pixbuf (GtkIconSource *source,
- GdkPixbuf *pixbuf)
-{
- g_return_if_fail (source != NULL);
- g_return_if_fail (pixbuf == NULL || GDK_IS_PIXBUF (pixbuf));
-
- if (source->type == GTK_ICON_SOURCE_PIXBUF &&
- source->source.pixbuf == pixbuf)
- return;
-
- icon_source_clear (source);
-
- if (pixbuf != NULL)
- {
- source->type = GTK_ICON_SOURCE_PIXBUF;
- source->source.pixbuf = g_object_ref (pixbuf);
- }
-}
-
-/**
- * gtk_icon_source_get_filename:
- * @source: a #GtkIconSource
- *
- * Retrieves the source filename, or %NULL if none is set. The
- * filename is not a copy, and should not be modified or expected to
- * persist beyond the lifetime of the icon source.
- *
- * Return value: (type filename): image filename. This string must not
- * be modified or freed.
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-const gchar*
-gtk_icon_source_get_filename (const GtkIconSource *source)
-{
- g_return_val_if_fail (source != NULL, NULL);
-
- if (source->type == GTK_ICON_SOURCE_FILENAME)
- return source->source.filename;
- else
- return NULL;
-}
-
-/**
- * gtk_icon_source_get_icon_name:
- * @source: a #GtkIconSource
- *
- * Retrieves the source icon name, or %NULL if none is set. The
- * icon_name is not a copy, and should not be modified or expected to
- * persist beyond the lifetime of the icon source.
- *
- * Return value: icon name. This string must not be modified or freed.
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-const gchar*
-gtk_icon_source_get_icon_name (const GtkIconSource *source)
-{
- g_return_val_if_fail (source != NULL, NULL);
-
- if (source->type == GTK_ICON_SOURCE_ICON_NAME ||
- source->type == GTK_ICON_SOURCE_STATIC_ICON_NAME)
- return source->source.icon_name;
- else
- return NULL;
-}
-
-/**
- * gtk_icon_source_get_pixbuf:
- * @source: a #GtkIconSource
- *
- * Retrieves the source pixbuf, or %NULL if none is set.
- * In addition, if a filename source is in use, this
- * function in some cases will return the pixbuf from
- * loaded from the filename. This is, for example, true
- * for the GtkIconSource passed to the GtkStyle::render_icon()
- * virtual function. The reference count on the pixbuf is
- * not incremented.
- *
- * Return value: (transfer none): source pixbuf
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-GdkPixbuf*
-gtk_icon_source_get_pixbuf (const GtkIconSource *source)
-{
- g_return_val_if_fail (source != NULL, NULL);
-
- if (source->type == GTK_ICON_SOURCE_PIXBUF)
- return source->source.pixbuf;
- else if (source->type == GTK_ICON_SOURCE_FILENAME)
- return source->filename_pixbuf;
- else
- return NULL;
-}
-
-/**
- * gtk_icon_source_set_direction_wildcarded:
- * @source: a #GtkIconSource
- * @setting: %TRUE to wildcard the text direction
- *
- * If the text direction is wildcarded, this source can be used
- * as the base image for an icon in any #GtkTextDirection.
- * If the text direction is not wildcarded, then the
- * text direction the icon source applies to should be set
- * with gtk_icon_source_set_direction(), and the icon source
- * will only be used with that text direction.
- *
- * #GtkIconSet prefers non-wildcarded sources (exact matches) over
- * wildcarded sources, and will use an exact match when possible.
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-void
-gtk_icon_source_set_direction_wildcarded (GtkIconSource *source,
- gboolean setting)
-{
- g_return_if_fail (source != NULL);
-
- source->any_direction = setting != FALSE;
-}
-
-/**
- * gtk_icon_source_set_state_wildcarded:
- * @source: a #GtkIconSource
- * @setting: %TRUE to wildcard the widget state
- *
- * If the widget state is wildcarded, this source can be used as the
- * base image for an icon in any #GtkStateType. If the widget state
- * is not wildcarded, then the state the source applies to should be
- * set with gtk_icon_source_set_state() and the icon source will
- * only be used with that specific state.
- *
- * #GtkIconSet prefers non-wildcarded sources (exact matches) over
- * wildcarded sources, and will use an exact match when possible.
- *
- * #GtkIconSet will normally transform wildcarded source images to
- * produce an appropriate icon for a given state, for example
- * lightening an image on prelight, but will not modify source images
- * that match exactly.
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-void
-gtk_icon_source_set_state_wildcarded (GtkIconSource *source,
- gboolean setting)
-{
- g_return_if_fail (source != NULL);
-
- source->any_state = setting != FALSE;
-}
-
-
-/**
- * gtk_icon_source_set_size_wildcarded:
- * @source: a #GtkIconSource
- * @setting: %TRUE to wildcard the widget state
- *
- * If the icon size is wildcarded, this source can be used as the base
- * image for an icon of any size. If the size is not wildcarded, then
- * the size the source applies to should be set with
- * gtk_icon_source_set_size() and the icon source will only be used
- * with that specific size.
- *
- * #GtkIconSet prefers non-wildcarded sources (exact matches) over
- * wildcarded sources, and will use an exact match when possible.
- *
- * #GtkIconSet will normally scale wildcarded source images to produce
- * an appropriate icon at a given size, but will not change the size
- * of source images that match exactly.
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-void
-gtk_icon_source_set_size_wildcarded (GtkIconSource *source,
- gboolean setting)
-{
- g_return_if_fail (source != NULL);
-
- source->any_size = setting != FALSE;
-}
-
-/**
- * gtk_icon_source_get_size_wildcarded:
- * @source: a #GtkIconSource
- *
- * Gets the value set by gtk_icon_source_set_size_wildcarded().
- *
- * Return value: %TRUE if this icon source is a base for any icon size variant
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-gboolean
-gtk_icon_source_get_size_wildcarded (const GtkIconSource *source)
-{
- g_return_val_if_fail (source != NULL, TRUE);
-
- return source->any_size;
-}
-
-/**
- * gtk_icon_source_get_state_wildcarded:
- * @source: a #GtkIconSource
- *
- * Gets the value set by gtk_icon_source_set_state_wildcarded().
- *
- * Return value: %TRUE if this icon source is a base for any widget state variant
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-gboolean
-gtk_icon_source_get_state_wildcarded (const GtkIconSource *source)
-{
- g_return_val_if_fail (source != NULL, TRUE);
-
- return source->any_state;
-}
-
-/**
- * gtk_icon_source_get_direction_wildcarded:
- * @source: a #GtkIconSource
- *
- * Gets the value set by gtk_icon_source_set_direction_wildcarded().
- *
- * Return value: %TRUE if this icon source is a base for any text direction variant
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-gboolean
-gtk_icon_source_get_direction_wildcarded (const GtkIconSource *source)
-{
- g_return_val_if_fail (source != NULL, TRUE);
-
- return source->any_direction;
-}
-
-/**
- * gtk_icon_source_set_direction:
- * @source: a #GtkIconSource
- * @direction: text direction this source applies to
- *
- * Sets the text direction this icon source is intended to be used
- * with.
- *
- * Setting the text direction on an icon source makes no difference
- * if the text direction is wildcarded. Therefore, you should usually
- * call gtk_icon_source_set_direction_wildcarded() to un-wildcard it
- * in addition to calling this function.
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-void
-gtk_icon_source_set_direction (GtkIconSource *source,
- GtkTextDirection direction)
-{
- g_return_if_fail (source != NULL);
-
- source->direction = direction;
-}
-
-/**
- * gtk_icon_source_set_state:
- * @source: a #GtkIconSource
- * @state: widget state this source applies to
- *
- * Sets the widget state this icon source is intended to be used
- * with.
- *
- * Setting the widget state on an icon source makes no difference
- * if the state is wildcarded. Therefore, you should usually
- * call gtk_icon_source_set_state_wildcarded() to un-wildcard it
- * in addition to calling this function.
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-void
-gtk_icon_source_set_state (GtkIconSource *source,
- GtkStateType state)
-{
- g_return_if_fail (source != NULL);
-
- source->state = state;
-}
-
-/**
- * gtk_icon_source_set_size:
- * @source: a #GtkIconSource
- * @size: (type int): icon size this source applies to
- *
- * Sets the icon size this icon source is intended to be used
- * with.
- *
- * Setting the icon size on an icon source makes no difference
- * if the size is wildcarded. Therefore, you should usually
- * call gtk_icon_source_set_size_wildcarded() to un-wildcard it
- * in addition to calling this function.
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-void
-gtk_icon_source_set_size (GtkIconSource *source,
- GtkIconSize size)
-{
- g_return_if_fail (source != NULL);
-
- source->size = size;
-}
-
-/**
- * gtk_icon_source_get_direction:
- * @source: a #GtkIconSource
- *
- * Obtains the text direction this icon source applies to. The return
- * value is only useful/meaningful if the text direction is <emphasis>not</emphasis>
- * wildcarded.
- *
- * Return value: text direction this source matches
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-GtkTextDirection
-gtk_icon_source_get_direction (const GtkIconSource *source)
-{
- g_return_val_if_fail (source != NULL, 0);
-
- return source->direction;
-}
-
-/**
- * gtk_icon_source_get_state:
- * @source: a #GtkIconSource
- *
- * Obtains the widget state this icon source applies to. The return
- * value is only useful/meaningful if the widget state is <emphasis>not</emphasis>
- * wildcarded.
- *
- * Return value: widget state this source matches
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-GtkStateType
-gtk_icon_source_get_state (const GtkIconSource *source)
-{
- g_return_val_if_fail (source != NULL, 0);
-
- return source->state;
-}
-
-/**
- * gtk_icon_source_get_size:
- * @source: a #GtkIconSource
- *
- * Obtains the icon size this source applies to. The return value
- * is only useful/meaningful if the icon size is <emphasis>not</emphasis> wildcarded.
- *
- * Return value: (type int): icon size this source matches.
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-GtkIconSize
-gtk_icon_source_get_size (const GtkIconSource *source)
-{
- g_return_val_if_fail (source != NULL, 0);
-
- return source->size;
-}
-
-#define NUM_CACHED_ICONS 8
-
-typedef struct _CachedIcon CachedIcon;
-
-struct _CachedIcon
-{
- /* These must all match to use the cached pixbuf.
- * If any don't match, we must re-render the pixbuf.
- */
- GtkStyleContext *style;
- GtkTextDirection direction;
- GtkStateType state;
- GtkIconSize size;
- gint scale;
-
- GdkPixbuf *pixbuf;
-};
-
-static void
-ensure_cache_up_to_date (GtkIconSet *icon_set)
-{
- if (icon_set->cache_serial != cache_serial)
- {
- clear_cache (icon_set, TRUE);
- icon_set->cache_serial = cache_serial;
- }
-}
-
-static void
-cached_icon_free (CachedIcon *icon)
-{
- g_object_unref (icon->pixbuf);
- g_object_unref (icon->style);
-
- g_free (icon);
-}
-
-static GdkPixbuf *
-find_in_cache (GtkIconSet *icon_set,
- GtkStyleContext *style_context,
- GtkTextDirection direction,
- GtkStateType state,
- GtkIconSize size,
- gint scale)
-{
- GSList *tmp_list;
- GSList *prev;
-
- ensure_cache_up_to_date (icon_set);
-
- prev = NULL;
- tmp_list = icon_set->cache;
- while (tmp_list != NULL)
- {
- CachedIcon *icon = tmp_list->data;
-
- if (icon->style == style_context &&
- icon->direction == direction &&
- icon->state == state &&
- (size == (GtkIconSize)-1 || icon->size == size))
- {
- if (prev)
- {
- /* Move this icon to the front of the list. */
- prev->next = tmp_list->next;
- tmp_list->next = icon_set->cache;
- icon_set->cache = tmp_list;
- }
-
- return icon->pixbuf;
- }
-
- prev = tmp_list;
- tmp_list = g_slist_next (tmp_list);
- }
-
- return NULL;
-}
-
-static void
-add_to_cache (GtkIconSet *icon_set,
- GtkStyleContext *style_context,
- GtkTextDirection direction,
- GtkStateType state,
- GtkIconSize size,
- gint scale,
- GdkPixbuf *pixbuf)
-{
- CachedIcon *icon;
-
- ensure_cache_up_to_date (icon_set);
-
- g_object_ref (pixbuf);
-
- icon = g_new (CachedIcon, 1);
- icon_set->cache = g_slist_prepend (icon_set->cache, icon);
- icon_set->cache_size++;
-
- icon->style = g_object_ref (style_context);
- icon->direction = direction;
- icon->state = state;
- icon->size = size;
- icon->scale = scale;
- icon->pixbuf = pixbuf;
- attach_to_style (icon_set, icon->style);
-
- if (icon_set->cache_size >= NUM_CACHED_ICONS)
- {
- /* Remove oldest item in the cache */
- GSList *tmp_list;
-
- tmp_list = icon_set->cache;
-
- /* Find next-to-last link */
- g_assert (NUM_CACHED_ICONS > 2);
- while (tmp_list->next->next)
- tmp_list = tmp_list->next;
-
- g_assert (tmp_list != NULL);
- g_assert (tmp_list->next != NULL);
- g_assert (tmp_list->next->next == NULL);
-
- /* Free the last icon */
- icon = tmp_list->next->data;
-
- g_slist_free (tmp_list->next);
- tmp_list->next = NULL;
-
- cached_icon_free (icon);
- }
-}
-
-static void
-clear_cache (GtkIconSet *icon_set,
- gboolean style_detach)
-{
- GSList *cache, *tmp_list;
- GtkStyleContext *last_style = NULL;
-
- cache = icon_set->cache;
- icon_set->cache = NULL;
- icon_set->cache_size = 0;
- tmp_list = cache;
- while (tmp_list != NULL)
- {
- CachedIcon *icon = tmp_list->data;
-
- if (style_detach)
- {
- /* simple optimization for the case where the cache
- * contains contiguous icons from the same style.
- * it's safe to call detach_from_style more than
- * once on the same style though.
- */
- if (last_style != icon->style)
- {
- detach_from_style (icon_set, icon->style);
- last_style = icon->style;
- }
- }
-
- cached_icon_free (icon);
-
- tmp_list = g_slist_next (tmp_list);
- }
-
- g_slist_free (cache);
-}
-
-static GSList*
-copy_cache (GtkIconSet *icon_set,
- GtkIconSet *copy_recipient)
-{
- GSList *tmp_list;
- GSList *copy = NULL;
-
- ensure_cache_up_to_date (icon_set);
-
- tmp_list = icon_set->cache;
- while (tmp_list != NULL)
- {
- CachedIcon *icon = tmp_list->data;
- CachedIcon *icon_copy = g_new (CachedIcon, 1);
-
- *icon_copy = *icon;
-
- attach_to_style (copy_recipient, icon_copy->style);
- g_object_ref (icon_copy->style);
-
- g_object_ref (icon_copy->pixbuf);
-
- icon_copy->size = icon->size;
-
- copy = g_slist_prepend (copy, icon_copy);
-
- tmp_list = g_slist_next (tmp_list);
- }
-
- return g_slist_reverse (copy);
-}
-
-static void
-attach_to_style (GtkIconSet *icon_set,
- GtkStyleContext *style_context)
-{
- GHashTable *table;
-
- table = g_object_get_qdata (G_OBJECT (style_context),
- g_quark_try_string ("gtk-style-icon-sets"));
-
- if (table == NULL)
- {
- table = g_hash_table_new (NULL, NULL);
- g_object_set_qdata_full (G_OBJECT (style_context),
- g_quark_from_static_string ("gtk-style-icon-sets"),
- table,
- style_dnotify);
- }
-
- g_hash_table_insert (table, icon_set, icon_set);
-}
-
-static void
-detach_from_style (GtkIconSet *icon_set,
- GtkStyleContext *style_context)
-{
- GHashTable *table;
-
- table = g_object_get_qdata (G_OBJECT (style_context),
- g_quark_try_string ("gtk-style-icon-sets"));
-
- if (table != NULL)
- g_hash_table_remove (table, icon_set);
-}
-
-static void
-iconsets_foreach (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- GtkIconSet *icon_set = key;
-
- /* We only need to remove cache entries for the given style;
- * but that complicates things because in destroy notify
- * we don't know which style got destroyed, and 95% of the
- * time all cache entries will have the same style,
- * so this is faster anyway.
- */
-
- clear_cache (icon_set, FALSE);
-}
-
-static void
-style_dnotify (gpointer data)
-{
- GHashTable *table = data;
-
- g_hash_table_foreach (table, iconsets_foreach, NULL);
-
- g_hash_table_destroy (table);
-}
-
-/* This allows the icon set to detect that its cache is out of date. */
-void
-_gtk_icon_set_invalidate_caches (void)
-{
- ++cache_serial;
-}
-
-/**
- * _gtk_icon_factory_list_ids:
- *
- * Gets all known IDs stored in an existing icon factory.
- * The strings in the returned list aren't copied.
- * The list itself should be freed.
- *
- * Return value: List of ids in icon factories
- *
- * Deprecated: 3.10: Use #GtkIconTheme instead.
- */
-GList*
-_gtk_icon_factory_list_ids (void)
-{
- GSList *tmp_list;
- GList *ids;
-
- ids = NULL;
-
- _gtk_icon_factory_get_default_icons ();
-
- tmp_list = all_icon_factories;
- while (tmp_list != NULL)
- {
- GList *these_ids;
- GtkIconFactory *factory = GTK_ICON_FACTORY (tmp_list->data);
- GtkIconFactoryPrivate *priv = factory->priv;
-
- these_ids = g_hash_table_get_keys (priv->icons);
-
- ids = g_list_concat (ids, these_ids);
-
- tmp_list = g_slist_next (tmp_list);
- }
-
- return ids;
-}
-
-typedef struct {
- GSList *sources;
- gboolean in_source;
-
-} IconFactoryParserData;
-
-typedef struct {
- gchar *stock_id;
- gchar *filename;
- gchar *icon_name;
- GtkTextDirection direction;
- GtkIconSize size;
- GtkStateType state;
-} IconSourceParserData;
-
-static void
-icon_source_start_element (GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **names,
- const gchar **values,
- gpointer user_data,
- GError **error)
-{
- gint i;
- gchar *stock_id = NULL;
- gchar *filename = NULL;
- gchar *icon_name = NULL;
- gint size = -1;
- gint direction = -1;
- gint state = -1;
- IconFactoryParserData *parser_data;
- IconSourceParserData *source_data;
- gchar *error_msg;
- GQuark error_domain;
-
- parser_data = (IconFactoryParserData*)user_data;
-
- if (!parser_data->in_source)
- {
- if (strcmp (element_name, "sources") != 0)
- {
- error_msg = g_strdup_printf ("Unexpected element %s, expected <sources>", element_name);
- error_domain = GTK_BUILDER_ERROR_INVALID_TAG;
- goto error;
- }
- parser_data->in_source = TRUE;
- return;
- }
- else
- {
- if (strcmp (element_name, "source") != 0)
- {
- error_msg = g_strdup_printf ("Unexpected element %s, expected <source>", element_name);
- error_domain = GTK_BUILDER_ERROR_INVALID_TAG;
- goto error;
- }
- }
-
- for (i = 0; names[i]; i++)
- {
- if (strcmp (names[i], "stock-id") == 0)
- stock_id = g_strdup (values[i]);
- else if (strcmp (names[i], "filename") == 0)
- filename = g_strdup (values[i]);
- else if (strcmp (names[i], "icon-name") == 0)
- icon_name = g_strdup (values[i]);
- else if (strcmp (names[i], "size") == 0)
- {
- if (!_gtk_builder_enum_from_string (GTK_TYPE_ICON_SIZE,
- values[i],
- &size,
- error))
- return;
- }
- else if (strcmp (names[i], "direction") == 0)
- {
- if (!_gtk_builder_enum_from_string (GTK_TYPE_TEXT_DIRECTION,
- values[i],
- &direction,
- error))
- return;
- }
- else if (strcmp (names[i], "state") == 0)
- {
- if (!_gtk_builder_enum_from_string (GTK_TYPE_STATE_TYPE,
- values[i],
- &state,
- error))
- return;
- }
- else
- {
- error_msg = g_strdup_printf ("'%s' is not a valid attribute of <%s>",
- names[i], "source");
- error_domain = GTK_BUILDER_ERROR_INVALID_ATTRIBUTE;
- goto error;
- }
- }
-
- if (!stock_id)
- {
- error_msg = g_strdup_printf ("<source> requires a stock_id");
- error_domain = GTK_BUILDER_ERROR_MISSING_ATTRIBUTE;
- goto error;
- }
-
- source_data = g_slice_new (IconSourceParserData);
- source_data->stock_id = stock_id;
- source_data->filename = filename;
- source_data->icon_name = icon_name;
- source_data->size = size;
- source_data->direction = direction;
- source_data->state = state;
-
- parser_data->sources = g_slist_prepend (parser_data->sources, source_data);
- return;
-
- error:
- {
- gchar *tmp;
- gint line_number, char_number;
-
- g_markup_parse_context_get_position (context, &line_number, &char_number);
-
- tmp = g_strdup_printf ("%s:%d:%d %s", "input",
- line_number, char_number, error_msg);
- g_set_error_literal (error, GTK_BUILDER_ERROR, error_domain, tmp);
- g_free (tmp);
- g_free (stock_id);
- g_free (filename);
- g_free (icon_name);
- return;
- }
-}
-
-static const GMarkupParser icon_source_parser =
- {
- icon_source_start_element,
- };
-
-static gboolean
-gtk_icon_factory_buildable_custom_tag_start (GtkBuildable *buildable,
- GtkBuilder *builder,
- GObject *child,
- const gchar *tagname,
- GMarkupParser *parser,
- gpointer *data)
-{
- g_assert (buildable);
-
- if (strcmp (tagname, "sources") == 0)
- {
- IconFactoryParserData *parser_data;
-
- parser_data = g_slice_new0 (IconFactoryParserData);
- *parser = icon_source_parser;
- *data = parser_data;
- return TRUE;
- }
- return FALSE;
-}
-
-static void
-gtk_icon_factory_buildable_custom_tag_end (GtkBuildable *buildable,
- GtkBuilder *builder,
- GObject *child,
- const gchar *tagname,
- gpointer *user_data)
-{
- GtkIconFactory *icon_factory;
-
- icon_factory = GTK_ICON_FACTORY (buildable);
-
- if (strcmp (tagname, "sources") == 0)
- {
- IconFactoryParserData *parser_data;
- GtkIconSource *icon_source;
- GtkIconSet *icon_set;
- GSList *l;
-
- parser_data = (IconFactoryParserData*)user_data;
-
- for (l = parser_data->sources; l; l = l->next)
- {
- IconSourceParserData *source_data = l->data;
-
- icon_set = gtk_icon_factory_lookup (icon_factory, source_data->stock_id);
- if (!icon_set)
- {
- icon_set = gtk_icon_set_new ();
- gtk_icon_factory_add (icon_factory, source_data->stock_id, icon_set);
- gtk_icon_set_unref (icon_set);
- }
-
- icon_source = gtk_icon_source_new ();
-
- if (source_data->filename)
- {
- gchar *filename;
- filename = _gtk_builder_get_absolute_filename (builder, source_data->filename);
- gtk_icon_source_set_filename (icon_source, filename);
- g_free (filename);
- }
- if (source_data->icon_name)
- gtk_icon_source_set_icon_name (icon_source, source_data->icon_name);
- if (source_data->size != -1)
- {
- gtk_icon_source_set_size (icon_source, source_data->size);
- gtk_icon_source_set_size_wildcarded (icon_source, FALSE);
- }
- if (source_data->direction != -1)
- {
- gtk_icon_source_set_direction (icon_source, source_data->direction);
- gtk_icon_source_set_direction_wildcarded (icon_source, FALSE);
- }
- if (source_data->state != -1)
- {
- gtk_icon_source_set_state (icon_source, source_data->state);
- gtk_icon_source_set_state_wildcarded (icon_source, FALSE);
- }
-
- /* Inline source_add() to avoid creating a copy */
- g_assert (icon_source->type != GTK_ICON_SOURCE_EMPTY);
- icon_set->sources = g_slist_insert_sorted (icon_set->sources,
- icon_source,
- icon_source_compare);
-
- g_free (source_data->stock_id);
- g_free (source_data->filename);
- g_free (source_data->icon_name);
- g_slice_free (IconSourceParserData, source_data);
- }
- g_slist_free (parser_data->sources);
- g_slice_free (IconFactoryParserData, parser_data);
-
- /* TODO: Add an attribute/tag to prevent this.
- * Usually it's the right thing to do though.
- */
- gtk_icon_factory_add_default (icon_factory);
- }
-}
+++ /dev/null
-/* GTK - The GIMP Toolkit
- * Copyright (C) 2000 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#ifndef __GTK_ICON_FACTORY_H__
-#define __GTK_ICON_FACTORY_H__
-
-#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
-#error "Only <gtk/gtk.h> can be included directly."
-#endif
-
-#include <gdk/gdk.h>
-#include <gtk/gtkenums.h>
-#include <gtk/gtktypes.h>
-
-G_BEGIN_DECLS
-
-
-#define GTK_TYPE_ICON_FACTORY (gtk_icon_factory_get_type ())
-#define GTK_ICON_FACTORY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_ICON_FACTORY, GtkIconFactory))
-#define GTK_ICON_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ICON_FACTORY, GtkIconFactoryClass))
-#define GTK_IS_ICON_FACTORY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GTK_TYPE_ICON_FACTORY))
-#define GTK_IS_ICON_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ICON_FACTORY))
-#define GTK_ICON_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ICON_FACTORY, GtkIconFactoryClass))
-#define GTK_TYPE_ICON_SET (gtk_icon_set_get_type ())
-#define GTK_TYPE_ICON_SOURCE (gtk_icon_source_get_type ())
-
-typedef struct _GtkIconFactory GtkIconFactory;
-typedef struct _GtkIconFactoryPrivate GtkIconFactoryPrivate;
-typedef struct _GtkIconFactoryClass GtkIconFactoryClass;
-
-struct _GtkIconFactory
-{
- GObject parent_instance;
-
- /*< private >*/
- GtkIconFactoryPrivate *priv;
-};
-
-struct _GtkIconFactoryClass
-{
- GObjectClass parent_class;
-
- /* Padding for future expansion */
- void (*_gtk_reserved1) (void);
- void (*_gtk_reserved2) (void);
- void (*_gtk_reserved3) (void);
- void (*_gtk_reserved4) (void);
-};
-
-GDK_DEPRECATED_IN_3_10
-GType gtk_icon_factory_get_type (void) G_GNUC_CONST;
-GDK_DEPRECATED_IN_3_10
-GtkIconFactory* gtk_icon_factory_new (void);
-GDK_DEPRECATED_IN_3_10
-void gtk_icon_factory_add (GtkIconFactory *factory,
- const gchar *stock_id,
- GtkIconSet *icon_set);
-GDK_DEPRECATED_IN_3_10
-GtkIconSet* gtk_icon_factory_lookup (GtkIconFactory *factory,
- const gchar *stock_id);
-
-/* Manage the default icon factory stack */
-
-GDK_DEPRECATED_IN_3_10
-void gtk_icon_factory_add_default (GtkIconFactory *factory);
-GDK_DEPRECATED_IN_3_10
-void gtk_icon_factory_remove_default (GtkIconFactory *factory);
-GDK_DEPRECATED_IN_3_10
-GtkIconSet* gtk_icon_factory_lookup_default (const gchar *stock_id);
-
-/* Get preferred real size from registered semantic size. Note that
- * themes SHOULD use this size, but they aren't required to; for size
- * requests and such, you should get the actual pixbuf from the icon
- * set and see what size was rendered.
- *
- * This function is intended for people who are scaling icons,
- * rather than for people who are displaying already-scaled icons.
- * That is, if you are displaying an icon, you should get the
- * size from the rendered pixbuf, not from here.
- */
-
-#ifndef GDK_MULTIHEAD_SAFE
-GDK_AVAILABLE_IN_ALL
-gboolean gtk_icon_size_lookup (GtkIconSize size,
- gint *width,
- gint *height);
-#endif /* GDK_MULTIHEAD_SAFE */
-GDK_DEPRECATED_IN_3_10_FOR(gtk_icon_size_lookup)
-gboolean gtk_icon_size_lookup_for_settings (GtkSettings *settings,
- GtkIconSize size,
- gint *width,
- gint *height);
-
-GDK_DEPRECATED_IN_3_10
-GtkIconSize gtk_icon_size_register (const gchar *name,
- gint width,
- gint height);
-GDK_DEPRECATED_IN_3_10
-void gtk_icon_size_register_alias (const gchar *alias,
- GtkIconSize target);
-GDK_DEPRECATED_IN_3_10
-GtkIconSize gtk_icon_size_from_name (const gchar *name);
-GDK_DEPRECATED_IN_3_10
-const gchar* gtk_icon_size_get_name (GtkIconSize size);
-
-/* Icon sets */
-
-GDK_DEPRECATED_IN_3_10
-GType gtk_icon_set_get_type (void) G_GNUC_CONST;
-GDK_DEPRECATED_IN_3_10
-GtkIconSet* gtk_icon_set_new (void);
-GDK_DEPRECATED_IN_3_10
-GtkIconSet* gtk_icon_set_new_from_pixbuf (GdkPixbuf *pixbuf);
-
-GDK_DEPRECATED_IN_3_10
-GtkIconSet* gtk_icon_set_ref (GtkIconSet *icon_set);
-GDK_DEPRECATED_IN_3_10
-void gtk_icon_set_unref (GtkIconSet *icon_set);
-GDK_DEPRECATED_IN_3_10
-GtkIconSet* gtk_icon_set_copy (GtkIconSet *icon_set);
-
-GDK_DEPRECATED_IN_3_0_FOR(gtk_icon_set_render_icon_pixbuf)
-GdkPixbuf* gtk_icon_set_render_icon (GtkIconSet *icon_set,
- GtkStyle *style,
- GtkTextDirection direction,
- GtkStateType state,
- GtkIconSize size,
- GtkWidget *widget,
- const gchar *detail);
-
-GDK_DEPRECATED_IN_3_10
-void gtk_icon_set_add_source (GtkIconSet *icon_set,
- const GtkIconSource *source);
-
-GDK_DEPRECATED_IN_3_10
-void gtk_icon_set_get_sizes (GtkIconSet *icon_set,
- GtkIconSize **sizes,
- gint *n_sizes);
-
-GDK_DEPRECATED_IN_3_10
-GType gtk_icon_source_get_type (void) G_GNUC_CONST;
-GDK_DEPRECATED_IN_3_10
-GtkIconSource* gtk_icon_source_new (void);
-GDK_DEPRECATED_IN_3_10
-GtkIconSource* gtk_icon_source_copy (const GtkIconSource *source);
-GDK_DEPRECATED_IN_3_10
-void gtk_icon_source_free (GtkIconSource *source);
-
-GDK_DEPRECATED_IN_3_10
-void gtk_icon_source_set_filename (GtkIconSource *source,
- const gchar *filename);
-GDK_DEPRECATED_IN_3_10
-void gtk_icon_source_set_icon_name (GtkIconSource *source,
- const gchar *icon_name);
-GDK_DEPRECATED_IN_3_10
-void gtk_icon_source_set_pixbuf (GtkIconSource *source,
- GdkPixbuf *pixbuf);
-
-GDK_DEPRECATED_IN_3_10
-const gchar * gtk_icon_source_get_filename (const GtkIconSource *source);
-GDK_DEPRECATED_IN_3_10
-const gchar * gtk_icon_source_get_icon_name (const GtkIconSource *source);
-GDK_DEPRECATED_IN_3_10
-GdkPixbuf* gtk_icon_source_get_pixbuf (const GtkIconSource *source);
-
-GDK_DEPRECATED_IN_3_10
-void gtk_icon_source_set_direction_wildcarded (GtkIconSource *source,
- gboolean setting);
-GDK_DEPRECATED_IN_3_10
-void gtk_icon_source_set_state_wildcarded (GtkIconSource *source,
- gboolean setting);
-GDK_DEPRECATED_IN_3_10
-void gtk_icon_source_set_size_wildcarded (GtkIconSource *source,
- gboolean setting);
-GDK_DEPRECATED_IN_3_10
-gboolean gtk_icon_source_get_size_wildcarded (const GtkIconSource *source);
-GDK_DEPRECATED_IN_3_10
-gboolean gtk_icon_source_get_state_wildcarded (const GtkIconSource *source);
-GDK_DEPRECATED_IN_3_10
-gboolean gtk_icon_source_get_direction_wildcarded (const GtkIconSource *source);
-GDK_DEPRECATED_IN_3_10
-void gtk_icon_source_set_direction (GtkIconSource *source,
- GtkTextDirection direction);
-GDK_DEPRECATED_IN_3_10
-void gtk_icon_source_set_state (GtkIconSource *source,
- GtkStateType state);
-GDK_DEPRECATED_IN_3_10
-void gtk_icon_source_set_size (GtkIconSource *source,
- GtkIconSize size);
-GDK_DEPRECATED_IN_3_10
-GtkTextDirection gtk_icon_source_get_direction (const GtkIconSource *source);
-GDK_DEPRECATED_IN_3_10
-GtkStateType gtk_icon_source_get_state (const GtkIconSource *source);
-GDK_DEPRECATED_IN_3_10
-GtkIconSize gtk_icon_source_get_size (const GtkIconSource *source);
-
-
-/* ignore this */
-void _gtk_icon_set_invalidate_caches (void);
-GList* _gtk_icon_factory_list_ids (void);
-void _gtk_icon_factory_ensure_default_icons (void);
-
-G_END_DECLS
-
-#endif /* __GTK_ICON_FACTORY_H__ */
#include "gtkicontheme.h"
#include "gtkdebug.h"
-#include "gtkiconfactory.h"
+#include "deprecated/gtkiconfactory.h"
#include "gtkiconcache.h"
#include "gtkbuiltincache.h"
#include "gtkintl.h"
#include "gtkcontainer.h"
#include "gtkiconhelperprivate.h"
#include "gtkimageprivate.h"
-#include "gtkiconfactory.h"
-#include "gtkstock.h"
+#include "deprecated/gtkiconfactory.h"
+#include "deprecated/gtkstock.h"
#include "gtkicontheme.h"
#include "gtksizerequest.h"
#include "gtkintl.h"
+++ /dev/null
-/* GTK - The GIMP Toolkit
- * Copyright (C) 2001 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#include "config.h"
-
-#define GDK_DISABLE_DEPRECATION_WARNINGS
-
-#include "gtkimagemenuitem.h"
-
-#include "gtkmenuitemprivate.h"
-#include "gtkaccellabel.h"
-#include "gtkstock.h"
-#include "gtkiconfactory.h"
-#include "gtkimage.h"
-#include "gtkmenubar.h"
-#include "gtkcontainer.h"
-#include "gtkwindow.h"
-#include "gtkactivatable.h"
-
-#include "gtkintl.h"
-#include "gtkprivate.h"
-
-
-/**
- * SECTION:gtkimagemenuitem
- * @Short_description: A menu item with an icon
- * @Title: GtkImageMenuItem
- *
- * A GtkImageMenuItem is a menu item which has an icon next to the text label.
- *
- * Note that the user can disable display of menu icons, so make sure to still
- * fill in the text label.
- */
-
-
-struct _GtkImageMenuItemPrivate
-{
- GtkWidget *image;
-
- gchar *label;
- guint use_stock : 1;
- guint always_show_image : 1;
-};
-
-enum {
- PROP_0,
- PROP_IMAGE,
- PROP_USE_STOCK,
- PROP_ACCEL_GROUP,
- PROP_ALWAYS_SHOW_IMAGE
-};
-
-static GtkActivatableIface *parent_activatable_iface;
-
-static void gtk_image_menu_item_destroy (GtkWidget *widget);
-static void gtk_image_menu_item_get_preferred_width (GtkWidget *widget,
- gint *minimum,
- gint *natural);
-static void gtk_image_menu_item_get_preferred_height (GtkWidget *widget,
- gint *minimum,
- gint *natural);
-static void gtk_image_menu_item_get_preferred_height_for_width (GtkWidget *widget,
- gint width,
- gint *minimum,
- gint *natural);
-static void gtk_image_menu_item_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static void gtk_image_menu_item_map (GtkWidget *widget);
-static void gtk_image_menu_item_remove (GtkContainer *container,
- GtkWidget *child);
-static void gtk_image_menu_item_toggle_size_request (GtkMenuItem *menu_item,
- gint *requisition);
-static void gtk_image_menu_item_set_label (GtkMenuItem *menu_item,
- const gchar *label);
-static const gchar * gtk_image_menu_item_get_label (GtkMenuItem *menu_item);
-
-static void gtk_image_menu_item_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-
-static void gtk_image_menu_item_finalize (GObject *object);
-static void gtk_image_menu_item_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gtk_image_menu_item_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static void gtk_image_menu_item_recalculate (GtkImageMenuItem *image_menu_item);
-
-static void gtk_image_menu_item_activatable_interface_init (GtkActivatableIface *iface);
-static void gtk_image_menu_item_update (GtkActivatable *activatable,
- GtkAction *action,
- const gchar *property_name);
-static void gtk_image_menu_item_sync_action_properties (GtkActivatable *activatable,
- GtkAction *action);
-
-
-G_DEFINE_TYPE_WITH_CODE (GtkImageMenuItem, gtk_image_menu_item, GTK_TYPE_MENU_ITEM,
- G_ADD_PRIVATE (GtkImageMenuItem)
- G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE,
- gtk_image_menu_item_activatable_interface_init))
-
-
-static void
-gtk_image_menu_item_class_init (GtkImageMenuItemClass *klass)
-{
- GObjectClass *gobject_class = (GObjectClass*) klass;
- GtkWidgetClass *widget_class = (GtkWidgetClass*) klass;
- GtkMenuItemClass *menu_item_class = (GtkMenuItemClass*) klass;
- GtkContainerClass *container_class = (GtkContainerClass*) klass;
-
- widget_class->destroy = gtk_image_menu_item_destroy;
- widget_class->get_preferred_width = gtk_image_menu_item_get_preferred_width;
- widget_class->get_preferred_height = gtk_image_menu_item_get_preferred_height;
- widget_class->get_preferred_height_for_width = gtk_image_menu_item_get_preferred_height_for_width;
- widget_class->size_allocate = gtk_image_menu_item_size_allocate;
- widget_class->map = gtk_image_menu_item_map;
-
- container_class->forall = gtk_image_menu_item_forall;
- container_class->remove = gtk_image_menu_item_remove;
-
- menu_item_class->toggle_size_request = gtk_image_menu_item_toggle_size_request;
- menu_item_class->set_label = gtk_image_menu_item_set_label;
- menu_item_class->get_label = gtk_image_menu_item_get_label;
-
- gobject_class->finalize = gtk_image_menu_item_finalize;
- gobject_class->set_property = gtk_image_menu_item_set_property;
- gobject_class->get_property = gtk_image_menu_item_get_property;
-
- /**
- * GtkImageMenuItem:image:
- *
- * Child widget to appear next to the menu text.
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_IMAGE,
- g_param_spec_object ("image",
- P_("Image widget"),
- P_("Child widget to appear next to the menu text"),
- GTK_TYPE_WIDGET,
- GTK_PARAM_READWRITE | G_PARAM_DEPRECATED));
- /**
- * GtkImageMenuItem:use-stock:
- *
- * If %TRUE, the label set in the menuitem is used as a
- * stock id to select the stock item for the item.
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_USE_STOCK,
- g_param_spec_boolean ("use-stock",
- P_("Use stock"),
- P_("Whether to use the label text to create a stock menu item"),
- FALSE,
- GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_DEPRECATED));
-
- /**
- * GtkImageMenuItem:always-show-image:
- *
- * If %TRUE, the menu item will always show the image, if available.
- *
- * Use this property only if the menuitem would be useless or hard to use
- * without the image.
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_ALWAYS_SHOW_IMAGE,
- g_param_spec_boolean ("always-show-image",
- P_("Always show image"),
- P_("Whether the image will always be shown"),
- FALSE,
- GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_DEPRECATED));
-
- /**
- * GtkImageMenuItem:accel-group:
- *
- * The Accel Group to use for stock accelerator keys
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_ACCEL_GROUP,
- g_param_spec_object ("accel-group",
- P_("Accel Group"),
- P_("The Accel Group to use for stock accelerator keys"),
- GTK_TYPE_ACCEL_GROUP,
- GTK_PARAM_WRITABLE | G_PARAM_DEPRECATED));
-
-}
-
-static void
-gtk_image_menu_item_init (GtkImageMenuItem *image_menu_item)
-{
- GtkImageMenuItemPrivate *priv;
-
- image_menu_item->priv = gtk_image_menu_item_get_instance_private (image_menu_item);
- priv = image_menu_item->priv;
-
- priv->image = NULL;
- priv->use_stock = FALSE;
- priv->label = NULL;
-}
-
-static void
-gtk_image_menu_item_finalize (GObject *object)
-{
- GtkImageMenuItemPrivate *priv = GTK_IMAGE_MENU_ITEM (object)->priv;
-
- g_free (priv->label);
- priv->label = NULL;
-
- G_OBJECT_CLASS (gtk_image_menu_item_parent_class)->finalize (object);
-}
-
-static void
-gtk_image_menu_item_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (object);
-
- switch (prop_id)
- {
- case PROP_IMAGE:
- gtk_image_menu_item_set_image (image_menu_item, (GtkWidget *) g_value_get_object (value));
- break;
- case PROP_USE_STOCK:
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- gtk_image_menu_item_set_use_stock (image_menu_item, g_value_get_boolean (value));
- G_GNUC_END_IGNORE_DEPRECATIONS;
- break;
- case PROP_ALWAYS_SHOW_IMAGE:
- gtk_image_menu_item_set_always_show_image (image_menu_item, g_value_get_boolean (value));
- break;
- case PROP_ACCEL_GROUP:
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- gtk_image_menu_item_set_accel_group (image_menu_item, g_value_get_object (value));
- G_GNUC_END_IGNORE_DEPRECATIONS;
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gtk_image_menu_item_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (object);
-
- switch (prop_id)
- {
- case PROP_IMAGE:
- g_value_set_object (value, gtk_image_menu_item_get_image (image_menu_item));
- break;
- case PROP_USE_STOCK:
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- g_value_set_boolean (value, gtk_image_menu_item_get_use_stock (image_menu_item));
- G_GNUC_END_IGNORE_DEPRECATIONS;
- break;
- case PROP_ALWAYS_SHOW_IMAGE:
- g_value_set_boolean (value, gtk_image_menu_item_get_always_show_image (image_menu_item));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gtk_image_menu_item_map (GtkWidget *widget)
-{
- GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
- GtkImageMenuItemPrivate *priv = image_menu_item->priv;
-
- GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->map (widget);
-
- if (priv->image)
- g_object_set (priv->image,
- "visible", priv->always_show_image,
- NULL);
-}
-
-static void
-gtk_image_menu_item_destroy (GtkWidget *widget)
-{
- GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
- GtkImageMenuItemPrivate *priv = image_menu_item->priv;
-
- if (priv->image)
- gtk_container_remove (GTK_CONTAINER (image_menu_item),
- priv->image);
-
- GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->destroy (widget);
-}
-
-static void
-gtk_image_menu_item_toggle_size_request (GtkMenuItem *menu_item,
- gint *requisition)
-{
- GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (menu_item);
- GtkImageMenuItemPrivate *priv = image_menu_item->priv;
- GtkPackDirection pack_dir;
- GtkWidget *parent;
- GtkWidget *widget = GTK_WIDGET (menu_item);
-
- parent = gtk_widget_get_parent (widget);
-
- if (GTK_IS_MENU_BAR (parent))
- pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
- else
- pack_dir = GTK_PACK_DIRECTION_LTR;
-
- *requisition = 0;
-
- if (priv->image && gtk_widget_get_visible (priv->image))
- {
- GtkRequisition image_requisition;
- guint toggle_spacing;
-
- gtk_widget_get_preferred_size (priv->image, &image_requisition, NULL);
-
- gtk_widget_style_get (GTK_WIDGET (menu_item),
- "toggle-spacing", &toggle_spacing,
- NULL);
-
- if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL)
- {
- if (image_requisition.width > 0)
- *requisition = image_requisition.width + toggle_spacing;
- }
- else
- {
- if (image_requisition.height > 0)
- *requisition = image_requisition.height + toggle_spacing;
- }
- }
-}
-
-static void
-gtk_image_menu_item_recalculate (GtkImageMenuItem *image_menu_item)
-{
- GtkImageMenuItemPrivate *priv = image_menu_item->priv;
- GtkStockItem stock_item;
- GtkWidget *image;
- const gchar *resolved_label = priv->label;
-
- if (priv->use_stock && priv->label)
- {
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-
- if (!priv->image)
- {
- image = gtk_image_new_from_stock (priv->label, GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image (image_menu_item, image);
- }
-
- if (gtk_stock_lookup (priv->label, &stock_item))
- resolved_label = stock_item.label;
-
- gtk_menu_item_set_use_underline (GTK_MENU_ITEM (image_menu_item), TRUE);
-
- G_GNUC_END_IGNORE_DEPRECATIONS;
- }
-
- GTK_MENU_ITEM_CLASS
- (gtk_image_menu_item_parent_class)->set_label (GTK_MENU_ITEM (image_menu_item), resolved_label);
-
-}
-
-static void
-gtk_image_menu_item_set_label (GtkMenuItem *menu_item,
- const gchar *label)
-{
- GtkImageMenuItemPrivate *priv = GTK_IMAGE_MENU_ITEM (menu_item)->priv;
-
- if (priv->label != label)
- {
- g_free (priv->label);
- priv->label = g_strdup (label);
-
- gtk_image_menu_item_recalculate (GTK_IMAGE_MENU_ITEM (menu_item));
-
- g_object_notify (G_OBJECT (menu_item), "label");
-
- }
-}
-
-static const gchar *
-gtk_image_menu_item_get_label (GtkMenuItem *menu_item)
-{
- GtkImageMenuItemPrivate *priv = GTK_IMAGE_MENU_ITEM (menu_item)->priv;
-
- return priv->label;
-}
-
-static void
-gtk_image_menu_item_get_preferred_width (GtkWidget *widget,
- gint *minimum,
- gint *natural)
-{
- GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
- GtkImageMenuItemPrivate *priv = image_menu_item->priv;
- GtkPackDirection pack_dir;
- GtkWidget *parent;
-
- parent = gtk_widget_get_parent (widget);
-
- if (GTK_IS_MENU_BAR (parent))
- pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
- else
- pack_dir = GTK_PACK_DIRECTION_LTR;
-
- GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->get_preferred_width (widget, minimum, natural);
-
- if ((pack_dir == GTK_PACK_DIRECTION_TTB || pack_dir == GTK_PACK_DIRECTION_BTT) &&
- priv->image &&
- gtk_widget_get_visible (priv->image))
- {
- gint child_minimum, child_natural;
-
- gtk_widget_get_preferred_width (priv->image, &child_minimum, &child_natural);
-
- *minimum = MAX (*minimum, child_minimum);
- *natural = MAX (*natural, child_natural);
- }
-}
-
-static void
-gtk_image_menu_item_get_preferred_height (GtkWidget *widget,
- gint *minimum,
- gint *natural)
-{
- GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
- GtkImageMenuItemPrivate *priv = image_menu_item->priv;
- gint child_height = 0;
- GtkPackDirection pack_dir;
- GtkWidget *parent;
-
- parent = gtk_widget_get_parent (widget);
-
- if (GTK_IS_MENU_BAR (parent))
- pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
- else
- pack_dir = GTK_PACK_DIRECTION_LTR;
-
- if (priv->image && gtk_widget_get_visible (priv->image))
- {
- GtkRequisition child_requisition;
-
- gtk_widget_get_preferred_size (priv->image, &child_requisition, NULL);
-
- child_height = child_requisition.height;
- }
-
- GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->get_preferred_height (widget, minimum, natural);
-
- if (pack_dir == GTK_PACK_DIRECTION_RTL || pack_dir == GTK_PACK_DIRECTION_LTR)
- {
- *minimum = MAX (*minimum, child_height);
- *natural = MAX (*natural, child_height);
- }
-}
-
-static void
-gtk_image_menu_item_get_preferred_height_for_width (GtkWidget *widget,
- gint width,
- gint *minimum,
- gint *natural)
-{
- GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
- GtkImageMenuItemPrivate *priv = image_menu_item->priv;
- gint child_height = 0;
- GtkPackDirection pack_dir;
- GtkWidget *parent;
-
- parent = gtk_widget_get_parent (widget);
-
- if (GTK_IS_MENU_BAR (parent))
- pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
- else
- pack_dir = GTK_PACK_DIRECTION_LTR;
-
- if (priv->image && gtk_widget_get_visible (priv->image))
- {
- GtkRequisition child_requisition;
-
- gtk_widget_get_preferred_size (priv->image, &child_requisition, NULL);
-
- child_height = child_requisition.height;
- }
-
- GTK_WIDGET_CLASS
- (gtk_image_menu_item_parent_class)->get_preferred_height_for_width (widget, width, minimum, natural);
-
- if (pack_dir == GTK_PACK_DIRECTION_RTL || pack_dir == GTK_PACK_DIRECTION_LTR)
- {
- *minimum = MAX (*minimum, child_height);
- *natural = MAX (*natural, child_height);
- }
-}
-
-
-static void
-gtk_image_menu_item_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
- GtkImageMenuItemPrivate *priv = image_menu_item->priv;
- GtkAllocation widget_allocation;
- GtkPackDirection pack_dir;
- GtkWidget *parent;
-
- parent = gtk_widget_get_parent (widget);
-
- if (GTK_IS_MENU_BAR (parent))
- pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
- else
- pack_dir = GTK_PACK_DIRECTION_LTR;
-
- GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->size_allocate (widget, allocation);
-
- if (priv->image && gtk_widget_get_visible (priv->image))
- {
- gint x, y, offset;
- GtkStyleContext *context;
- GtkStateFlags state;
- GtkBorder padding;
- GtkRequisition child_requisition;
- GtkAllocation child_allocation;
- guint horizontal_padding, toggle_spacing;
- gint toggle_size;
-
- toggle_size = GTK_MENU_ITEM (image_menu_item)->priv->toggle_size;
- gtk_widget_style_get (widget,
- "horizontal-padding", &horizontal_padding,
- "toggle-spacing", &toggle_spacing,
- NULL);
-
- /* Man this is lame hardcoding action, but I can't
- * come up with a solution that's really better.
- */
-
- gtk_widget_get_preferred_size (priv->image, &child_requisition, NULL);
-
- gtk_widget_get_allocation (widget, &widget_allocation);
-
- context = gtk_widget_get_style_context (widget);
- state = gtk_widget_get_state_flags (widget);
- gtk_style_context_get_padding (context, state, &padding);
- offset = gtk_container_get_border_width (GTK_CONTAINER (image_menu_item));
-
- if (pack_dir == GTK_PACK_DIRECTION_LTR ||
- pack_dir == GTK_PACK_DIRECTION_RTL)
- {
- if ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) ==
- (pack_dir == GTK_PACK_DIRECTION_LTR))
- x = offset + horizontal_padding + padding.left +
- (toggle_size - toggle_spacing - child_requisition.width) / 2;
- else
- x = widget_allocation.width - offset - horizontal_padding - padding.right -
- toggle_size + toggle_spacing +
- (toggle_size - toggle_spacing - child_requisition.width) / 2;
-
- y = (widget_allocation.height - child_requisition.height) / 2;
- }
- else
- {
- if ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) ==
- (pack_dir == GTK_PACK_DIRECTION_TTB))
- y = offset + horizontal_padding + padding.top +
- (toggle_size - toggle_spacing - child_requisition.height) / 2;
- else
- y = widget_allocation.height - offset - horizontal_padding - padding.bottom -
- toggle_size + toggle_spacing +
- (toggle_size - toggle_spacing - child_requisition.height) / 2;
-
- x = (widget_allocation.width - child_requisition.width) / 2;
- }
-
- child_allocation.width = child_requisition.width;
- child_allocation.height = child_requisition.height;
- child_allocation.x = widget_allocation.x + MAX (x, 0);
- child_allocation.y = widget_allocation.y + MAX (y, 0);
-
- gtk_widget_size_allocate (priv->image, &child_allocation);
- }
-}
-
-static void
-gtk_image_menu_item_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data)
-{
- GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (container);
- GtkImageMenuItemPrivate *priv = image_menu_item->priv;
-
- GTK_CONTAINER_CLASS (gtk_image_menu_item_parent_class)->forall (container,
- include_internals,
- callback,
- callback_data);
-
- if (include_internals && priv->image)
- (* callback) (priv->image, callback_data);
-}
-
-
-static void
-gtk_image_menu_item_activatable_interface_init (GtkActivatableIface *iface)
-{
- parent_activatable_iface = g_type_interface_peek_parent (iface);
- iface->update = gtk_image_menu_item_update;
- iface->sync_action_properties = gtk_image_menu_item_sync_action_properties;
-}
-
-static gboolean
-activatable_update_stock_id (GtkImageMenuItem *image_menu_item, GtkAction *action)
-{
- GtkWidget *image;
- const gchar *stock_id = gtk_action_get_stock_id (action);
-
- image = gtk_image_menu_item_get_image (image_menu_item);
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-
- if (GTK_IS_IMAGE (image) &&
- stock_id && gtk_icon_factory_lookup_default (stock_id))
- {
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- gtk_image_set_from_stock (GTK_IMAGE (image), stock_id, GTK_ICON_SIZE_MENU);
- G_GNUC_END_IGNORE_DEPRECATIONS;
- return TRUE;
- }
-
- G_GNUC_END_IGNORE_DEPRECATIONS;
-
- return FALSE;
-}
-
-static gboolean
-activatable_update_gicon (GtkImageMenuItem *image_menu_item, GtkAction *action)
-{
- GtkWidget *image;
- GIcon *icon = gtk_action_get_gicon (action);
- const gchar *stock_id;
- gboolean ret = FALSE;
-
- stock_id = gtk_action_get_stock_id (action);
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-
- image = gtk_image_menu_item_get_image (image_menu_item);
-
- if (icon && GTK_IS_IMAGE (image) &&
- !(stock_id && gtk_icon_factory_lookup_default (stock_id)))
- {
- gtk_image_set_from_gicon (GTK_IMAGE (image), icon, GTK_ICON_SIZE_MENU);
- ret = TRUE;
- }
-
- G_GNUC_END_IGNORE_DEPRECATIONS;
-
- return ret;
-}
-
-static void
-activatable_update_icon_name (GtkImageMenuItem *image_menu_item, GtkAction *action)
-{
- GtkWidget *image;
- const gchar *icon_name = gtk_action_get_icon_name (action);
-
- image = gtk_image_menu_item_get_image (image_menu_item);
-
- if (GTK_IS_IMAGE (image) &&
- (gtk_image_get_storage_type (GTK_IMAGE (image)) == GTK_IMAGE_EMPTY ||
- gtk_image_get_storage_type (GTK_IMAGE (image)) == GTK_IMAGE_ICON_NAME))
- {
- gtk_image_set_from_icon_name (GTK_IMAGE (image), icon_name, GTK_ICON_SIZE_MENU);
- }
-}
-
-static void
-gtk_image_menu_item_update (GtkActivatable *activatable,
- GtkAction *action,
- const gchar *property_name)
-{
- GtkImageMenuItem *image_menu_item;
- gboolean use_appearance;
-
- image_menu_item = GTK_IMAGE_MENU_ITEM (activatable);
-
- parent_activatable_iface->update (activatable, action, property_name);
-
- use_appearance = gtk_activatable_get_use_action_appearance (activatable);
- if (!use_appearance)
- return;
-
- if (strcmp (property_name, "stock-id") == 0)
- activatable_update_stock_id (image_menu_item, action);
- else if (strcmp (property_name, "gicon") == 0)
- activatable_update_gicon (image_menu_item, action);
- else if (strcmp (property_name, "icon-name") == 0)
- activatable_update_icon_name (image_menu_item, action);
-}
-
-static void
-gtk_image_menu_item_sync_action_properties (GtkActivatable *activatable,
- GtkAction *action)
-{
- GtkImageMenuItem *image_menu_item;
- GtkWidget *image;
- gboolean use_appearance;
-
- image_menu_item = GTK_IMAGE_MENU_ITEM (activatable);
-
- parent_activatable_iface->sync_action_properties (activatable, action);
-
- if (!action)
- return;
-
- use_appearance = gtk_activatable_get_use_action_appearance (activatable);
- if (!use_appearance)
- return;
-
- image = gtk_image_menu_item_get_image (image_menu_item);
- if (image && !GTK_IS_IMAGE (image))
- {
- gtk_image_menu_item_set_image (image_menu_item, NULL);
- image = NULL;
- }
-
- if (!image)
- {
- image = gtk_image_new ();
- gtk_widget_show (image);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (activatable),
- image);
- }
-
- if (!activatable_update_stock_id (image_menu_item, action) &&
- !activatable_update_gicon (image_menu_item, action))
- activatable_update_icon_name (image_menu_item, action);
-
- gtk_image_menu_item_set_always_show_image (image_menu_item,
- gtk_action_get_always_show_image (action));
-}
-
-
-/**
- * gtk_image_menu_item_new:
- *
- * Creates a new #GtkImageMenuItem with an empty label.
- *
- * Returns: a new #GtkImageMenuItem
- *
- * Deprecated: 3.10: Use gtk_menu_item_new() instead.
- */
-GtkWidget*
-gtk_image_menu_item_new (void)
-{
- return g_object_new (GTK_TYPE_IMAGE_MENU_ITEM, NULL);
-}
-
-/**
- * gtk_image_menu_item_new_with_label:
- * @label: the text of the menu item.
- *
- * Creates a new #GtkImageMenuItem containing a label.
- *
- * Returns: a new #GtkImageMenuItem.
- *
- * Deprecated: 3.10: Use gtk_menu_item_new_with_label() instead.
- */
-GtkWidget*
-gtk_image_menu_item_new_with_label (const gchar *label)
-{
- return g_object_new (GTK_TYPE_IMAGE_MENU_ITEM,
- "label", label,
- NULL);
-}
-
-/**
- * gtk_image_menu_item_new_with_mnemonic:
- * @label: the text of the menu item, with an underscore in front of the
- * mnemonic character
- *
- * Creates a new #GtkImageMenuItem containing a label. The label
- * will be created using gtk_label_new_with_mnemonic(), so underscores
- * in @label indicate the mnemonic for the menu item.
- *
- * Returns: a new #GtkImageMenuItem
- *
- * Deprecated: 3.10: Use gtk_menu_item_new_with_mnemonic() instead.
- */
-GtkWidget*
-gtk_image_menu_item_new_with_mnemonic (const gchar *label)
-{
- return g_object_new (GTK_TYPE_IMAGE_MENU_ITEM,
- "use-underline", TRUE,
- "label", label,
- NULL);
-}
-
-/**
- * gtk_image_menu_item_new_from_stock:
- * @stock_id: the name of the stock item.
- * @accel_group: (allow-none): the #GtkAccelGroup to add the menu items
- * accelerator to, or %NULL.
- *
- * Creates a new #GtkImageMenuItem containing the image and text from a
- * stock item. Some stock ids have preprocessor macros like #GTK_STOCK_OK
- * and #GTK_STOCK_APPLY.
- *
- * If you want this menu item to have changeable accelerators, then pass in
- * %NULL for accel_group. Next call gtk_menu_item_set_accel_path() with an
- * appropriate path for the menu item, use gtk_stock_lookup() to look up the
- * standard accelerator for the stock item, and if one is found, call
- * gtk_accel_map_add_entry() to register it.
- *
- * Returns: a new #GtkImageMenuItem.
- *
- * Deprecated: 3.10: Use gtk_image_menu_item_new() instead.
- */
-GtkWidget*
-gtk_image_menu_item_new_from_stock (const gchar *stock_id,
- GtkAccelGroup *accel_group)
-{
- return g_object_new (GTK_TYPE_IMAGE_MENU_ITEM,
- "label", stock_id,
- "use-stock", TRUE,
- "accel-group", accel_group,
- NULL);
-}
-
-/**
- * gtk_image_menu_item_set_use_stock:
- * @image_menu_item: a #GtkImageMenuItem
- * @use_stock: %TRUE if the menuitem should use a stock item
- *
- * If %TRUE, the label set in the menuitem is used as a
- * stock id to select the stock item for the item.
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-void
-gtk_image_menu_item_set_use_stock (GtkImageMenuItem *image_menu_item,
- gboolean use_stock)
-{
- GtkImageMenuItemPrivate *priv;
-
- g_return_if_fail (GTK_IS_IMAGE_MENU_ITEM (image_menu_item));
-
- priv = image_menu_item->priv;
-
- if (priv->use_stock != use_stock)
- {
- priv->use_stock = use_stock;
-
- gtk_image_menu_item_recalculate (image_menu_item);
-
- g_object_notify (G_OBJECT (image_menu_item), "use-stock");
- }
-}
-
-/**
- * gtk_image_menu_item_get_use_stock:
- * @image_menu_item: a #GtkImageMenuItem
- *
- * Checks whether the label set in the menuitem is used as a
- * stock id to select the stock item for the item.
- *
- * Returns: %TRUE if the label set in the menuitem is used as a
- * stock id to select the stock item for the item
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-gboolean
-gtk_image_menu_item_get_use_stock (GtkImageMenuItem *image_menu_item)
-{
- g_return_val_if_fail (GTK_IS_IMAGE_MENU_ITEM (image_menu_item), FALSE);
-
- return image_menu_item->priv->use_stock;
-}
-
-/**
- * gtk_image_menu_item_set_always_show_image:
- * @image_menu_item: a #GtkImageMenuItem
- * @always_show: %TRUE if the menuitem should always show the image
- *
- * If %TRUE, the menu item will always show the image, if available.
- *
- * Use this property if the menuitem would be useless or hard to use
- * without the image.
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-void
-gtk_image_menu_item_set_always_show_image (GtkImageMenuItem *image_menu_item,
- gboolean always_show)
-{
- GtkImageMenuItemPrivate *priv;
-
- g_return_if_fail (GTK_IS_IMAGE_MENU_ITEM (image_menu_item));
-
- priv = image_menu_item->priv;
-
- if (priv->always_show_image != always_show)
- {
- priv->always_show_image = always_show;
-
- if (priv->image)
- {
- if (priv->always_show_image)
- gtk_widget_show (priv->image);
- else
- gtk_widget_hide (priv->image);
- }
-
- g_object_notify (G_OBJECT (image_menu_item), "always-show-image");
- }
-}
-
-/**
- * gtk_image_menu_item_get_always_show_image:
- * @image_menu_item: a #GtkImageMenuItem
- *
- * Returns whether the menu item will always show the image, if available.
- *
- * Returns: %TRUE if the menu item will always show the image
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-gboolean
-gtk_image_menu_item_get_always_show_image (GtkImageMenuItem *image_menu_item)
-{
- g_return_val_if_fail (GTK_IS_IMAGE_MENU_ITEM (image_menu_item), FALSE);
-
- return image_menu_item->priv->always_show_image;
-}
-
-
-/**
- * gtk_image_menu_item_set_accel_group:
- * @image_menu_item: a #GtkImageMenuItem
- * @accel_group: the #GtkAccelGroup
- *
- * Specifies an @accel_group to add the menu items accelerator to
- * (this only applies to stock items so a stock item must already
- * be set, make sure to call gtk_image_menu_item_set_use_stock()
- * and gtk_menu_item_set_label() with a valid stock item first).
- *
- * If you want this menu item to have changeable accelerators then
- * you shouldnt need this (see gtk_image_menu_item_new_from_stock()).
- *
- * Since: 2.16
- *
- * Deprecated: 3.10
- */
-void
-gtk_image_menu_item_set_accel_group (GtkImageMenuItem *image_menu_item,
- GtkAccelGroup *accel_group)
-{
- GtkImageMenuItemPrivate *priv;
- GtkStockItem stock_item;
-
- /* Silent return for the constructor */
- if (!accel_group)
- return;
-
- g_return_if_fail (GTK_IS_IMAGE_MENU_ITEM (image_menu_item));
- g_return_if_fail (GTK_IS_ACCEL_GROUP (accel_group));
-
- priv = image_menu_item->priv;
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-
- if (priv->use_stock && priv->label && gtk_stock_lookup (priv->label, &stock_item))
- if (stock_item.keyval)
- {
- gtk_widget_add_accelerator (GTK_WIDGET (image_menu_item),
- "activate",
- accel_group,
- stock_item.keyval,
- stock_item.modifier,
- GTK_ACCEL_VISIBLE);
-
- g_object_notify (G_OBJECT (image_menu_item), "accel-group");
- }
-
- G_GNUC_END_IGNORE_DEPRECATIONS;
-
-}
-
-/**
- * gtk_image_menu_item_set_image:
- * @image_menu_item: a #GtkImageMenuItem.
- * @image: (allow-none): a widget to set as the image for the menu item.
- *
- * Sets the image of @image_menu_item to the given widget.
- * Note that it depends on the show-menu-images setting whether
- * the image will be displayed or not.
- *
- * Deprecated: 3.10
- */
-void
-gtk_image_menu_item_set_image (GtkImageMenuItem *image_menu_item,
- GtkWidget *image)
-{
- GtkImageMenuItemPrivate *priv;
-
- g_return_if_fail (GTK_IS_IMAGE_MENU_ITEM (image_menu_item));
-
- priv = image_menu_item->priv;
-
- if (image == priv->image)
- return;
-
- if (priv->image)
- gtk_container_remove (GTK_CONTAINER (image_menu_item),
- priv->image);
-
- priv->image = image;
-
- if (image == NULL)
- return;
-
- gtk_widget_set_parent (image, GTK_WIDGET (image_menu_item));
- g_object_set (image,
- "visible", priv->always_show_image,
- "no-show-all", TRUE,
- NULL);
-
- g_object_notify (G_OBJECT (image_menu_item), "image");
-}
-
-/**
- * gtk_image_menu_item_get_image:
- * @image_menu_item: a #GtkImageMenuItem
- *
- * Gets the widget that is currently set as the image of @image_menu_item.
- * See gtk_image_menu_item_set_image().
- *
- * Return value: (transfer none): the widget set as image of @image_menu_item
- *
- * Deprecated: 3.10
- **/
-GtkWidget*
-gtk_image_menu_item_get_image (GtkImageMenuItem *image_menu_item)
-{
- g_return_val_if_fail (GTK_IS_IMAGE_MENU_ITEM (image_menu_item), NULL);
-
- return image_menu_item->priv->image;
-}
-
-static void
-gtk_image_menu_item_remove (GtkContainer *container,
- GtkWidget *child)
-{
- GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (container);
- GtkImageMenuItemPrivate *priv = image_menu_item->priv;
-
- if (child == priv->image)
- {
- gboolean widget_was_visible;
-
- widget_was_visible = gtk_widget_get_visible (child);
-
- gtk_widget_unparent (child);
- priv->image = NULL;
-
- if (widget_was_visible &&
- gtk_widget_get_visible (GTK_WIDGET (container)))
- gtk_widget_queue_resize (GTK_WIDGET (container));
-
- g_object_notify (G_OBJECT (image_menu_item), "image");
- }
- else
- {
- GTK_CONTAINER_CLASS (gtk_image_menu_item_parent_class)->remove (container, child);
- }
-}
+++ /dev/null
-/* GTK - The GIMP Toolkit
- * Copyright (C) Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#ifndef __GTK_IMAGE_MENU_ITEM_H__
-#define __GTK_IMAGE_MENU_ITEM_H__
-
-
-#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
-#error "Only <gtk/gtk.h> can be included directly."
-#endif
-
-#include <gtk/gtkmenuitem.h>
-
-
-G_BEGIN_DECLS
-
-#define GTK_TYPE_IMAGE_MENU_ITEM (gtk_image_menu_item_get_type ())
-#define GTK_IMAGE_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_IMAGE_MENU_ITEM, GtkImageMenuItem))
-#define GTK_IMAGE_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_IMAGE_MENU_ITEM, GtkImageMenuItemClass))
-#define GTK_IS_IMAGE_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_IMAGE_MENU_ITEM))
-#define GTK_IS_IMAGE_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_IMAGE_MENU_ITEM))
-#define GTK_IMAGE_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_IMAGE_MENU_ITEM, GtkImageMenuItemClass))
-
-
-typedef struct _GtkImageMenuItem GtkImageMenuItem;
-typedef struct _GtkImageMenuItemPrivate GtkImageMenuItemPrivate;
-typedef struct _GtkImageMenuItemClass GtkImageMenuItemClass;
-
-struct _GtkImageMenuItem
-{
- GtkMenuItem menu_item;
-
- /*< private >*/
- GtkImageMenuItemPrivate *priv;
-};
-
-struct _GtkImageMenuItemClass
-{
- GtkMenuItemClass parent_class;
-
- /* Padding for future expansion */
- void (*_gtk_reserved1) (void);
- void (*_gtk_reserved2) (void);
- void (*_gtk_reserved3) (void);
- void (*_gtk_reserved4) (void);
-};
-
-GDK_DEPRECATED_IN_3_10_FOR(gtk_menu_item_get_type)
-GType gtk_image_menu_item_get_type (void) G_GNUC_CONST;
-GDK_DEPRECATED_IN_3_10_FOR(gtk_menu_item_new)
-GtkWidget* gtk_image_menu_item_new (void);
-GDK_DEPRECATED_IN_3_10_FOR(gtk_menu_item_new_with_label)
-GtkWidget* gtk_image_menu_item_new_with_label (const gchar *label);
-GDK_DEPRECATED_IN_3_10_FOR(gtk_menu_item_new_with_mnemonic)
-GtkWidget* gtk_image_menu_item_new_with_mnemonic (const gchar *label);
-GDK_DEPRECATED_IN_3_10_FOR(gtk_menu_item_new)
-GtkWidget* gtk_image_menu_item_new_from_stock (const gchar *stock_id,
- GtkAccelGroup *accel_group);
-GDK_DEPRECATED_IN_3_10
-void gtk_image_menu_item_set_always_show_image (GtkImageMenuItem *image_menu_item,
- gboolean always_show);
-GDK_DEPRECATED_IN_3_10
-gboolean gtk_image_menu_item_get_always_show_image (GtkImageMenuItem *image_menu_item);
-GDK_DEPRECATED_IN_3_10
-void gtk_image_menu_item_set_image (GtkImageMenuItem *image_menu_item,
- GtkWidget *image);
-GDK_DEPRECATED_IN_3_10
-GtkWidget* gtk_image_menu_item_get_image (GtkImageMenuItem *image_menu_item);
-GDK_DEPRECATED_IN_3_10
-void gtk_image_menu_item_set_use_stock (GtkImageMenuItem *image_menu_item,
- gboolean use_stock);
-GDK_DEPRECATED_IN_3_10
-gboolean gtk_image_menu_item_get_use_stock (GtkImageMenuItem *image_menu_item);
-GDK_DEPRECATED_IN_3_10
-void gtk_image_menu_item_set_accel_group (GtkImageMenuItem *image_menu_item,
- GtkAccelGroup *accel_group);
-
-G_END_DECLS
-
-#endif /* __GTK_IMAGE_MENU_ITEM_H__ */
#include "gtkprivate.h"
#include "gtkorientable.h"
#include "gtktypebuiltins.h"
-#include "gtkstock.h"
+#include "deprecated/gtkstock.h"
/**
* SECTION:gtkinfobar
#include "gtkpango.h"
#include "gtkwindow.h"
#include "gtkclipboard.h"
-#include "gtkimagemenuitem.h"
+#include "deprecated/gtkimagemenuitem.h"
#include "gtkintl.h"
#include "gtkseparatormenuitem.h"
#include "gtktextutil.h"
#include "gtkclipboard.h"
#include "gtkdnd.h"
-#include "gtkimagemenuitem.h"
+#include "deprecated/gtkimagemenuitem.h"
#include "gtklabel.h"
#include "gtkmain.h"
#include "gtkmarshalers.h"
#include "gtkseparatormenuitem.h"
#include "gtkprivate.h"
#include "gtkbuildable.h"
-#include "gtkactivatable.h"
+#include "deprecated/gtkactivatable.h"
#include "gtkwidgetprivate.h"
#include "gtkintl.h"
#include "gtksettings.h"
#define __GTK_MENU_ITEM_PRIVATE_H__
#include <gtk/gtkmenuitem.h>
-#include <gtk/gtkaction.h>
+#include <gtk/deprecated/gtkaction.h>
#include <gtk/gtkactionhelper.h>
G_BEGIN_DECLS
#include "gtklabel.h"
#include "gtkbox.h"
#include "gtkimage.h"
-#include "gtkiconfactory.h"
+#include "deprecated/gtkiconfactory.h"
#include "gtkintl.h"
#include "gtkprivate.h"
#include "gtktypebuiltins.h"
#include "gtkcellrendererpixbuf.h"
#include "gtkscrolledwindow.h"
#include "gtkicontheme.h"
-#include "gtkimagemenuitem.h"
+#include "deprecated/gtkimagemenuitem.h"
#include "gtkmain.h"
#include <glib/gprintf.h>
#include "gtkprivate.h"
#include "gtkliststore.h"
-#include "gtkstock.h"
+#include "deprecated/gtkstock.h"
#include "gtktreeviewcolumn.h"
#include "gtktreeselection.h"
#include "gtktreemodel.h"
#include "gtkarrow.h"
#include "gtkbox.h"
#include "gtkdnd.h"
-#include "gtkiconfactory.h"
+#include "deprecated/gtkiconfactory.h"
#include "gtkicontheme.h"
#include "gtkimage.h"
#include "gtkintl.h"
#include "gtkcellrendererpixbuf.h"
#include "gtkfilechooserprivate.h"
#include "gtkicontheme.h"
-#include "gtkimagemenuitem.h"
+#include "deprecated/gtkimagemenuitem.h"
#include "gtkintl.h"
#include "gtkmain.h"
#include "gtkmarshalers.h"
#include "gtkspinbutton.h"
#include "gtkcellrendererpixbuf.h"
#include "gtkcellrenderertext.h"
-#include "gtkiconfactory.h"
+#include "deprecated/gtkiconfactory.h"
#include "gtkimage.h"
#include "gtktreeselection.h"
#include "gtknotebook.h"
+++ /dev/null
-/*
- * GTK - The GIMP Toolkit
- * Copyright (C) 1998, 1999 Red Hat, Inc.
- * All rights reserved.
- *
- * This Library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This Library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Author: James Henstridge <james@daa.com.au>
- *
- * Modified by the GTK+ Team and others 2003. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#include "config.h"
-
-#define GDK_DISABLE_DEPRECATION_WARNINGS
-
-#include "gtkradioaction.h"
-#include "gtkradiomenuitem.h"
-#include "gtktoggletoolbutton.h"
-#include "gtkintl.h"
-#include "gtkprivate.h"
-
-/**
- * SECTION:gtkradioaction
- * @Short_description: An action of which only one in a group can be active
- * @Title: GtkRadioAction
- *
- * A #GtkRadioAction is similar to #GtkRadioMenuItem. A number of radio
- * actions can be linked together so that only one may be active at any
- * one time.
- */
-
-
-struct _GtkRadioActionPrivate
-{
- GSList *group;
- gint value;
-};
-
-enum
-{
- CHANGED,
- LAST_SIGNAL
-};
-
-enum
-{
- PROP_0,
- PROP_VALUE,
- PROP_GROUP,
- PROP_CURRENT_VALUE
-};
-
-static void gtk_radio_action_finalize (GObject *object);
-static void gtk_radio_action_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gtk_radio_action_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void gtk_radio_action_activate (GtkAction *action);
-static GtkWidget *create_menu_item (GtkAction *action);
-
-
-G_DEFINE_TYPE_WITH_PRIVATE (GtkRadioAction, gtk_radio_action, GTK_TYPE_TOGGLE_ACTION)
-
-static guint radio_action_signals[LAST_SIGNAL] = { 0 };
-
-static void
-gtk_radio_action_class_init (GtkRadioActionClass *klass)
-{
- GObjectClass *gobject_class;
- GtkActionClass *action_class;
-
- gobject_class = G_OBJECT_CLASS (klass);
- action_class = GTK_ACTION_CLASS (klass);
-
- gobject_class->finalize = gtk_radio_action_finalize;
- gobject_class->set_property = gtk_radio_action_set_property;
- gobject_class->get_property = gtk_radio_action_get_property;
-
- action_class->activate = gtk_radio_action_activate;
-
- action_class->create_menu_item = create_menu_item;
-
- /**
- * GtkRadioAction:value:
- *
- * The value is an arbitrary integer which can be used as a
- * convenient way to determine which action in the group is
- * currently active in an ::activate or ::changed signal handler.
- * See gtk_radio_action_get_current_value() and #GtkRadioActionEntry
- * for convenient ways to get and set this property.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_VALUE,
- g_param_spec_int ("value",
- P_("The value"),
- P_("The value returned by gtk_radio_action_get_current_value() when this action is the current action of its group."),
- G_MININT,
- G_MAXINT,
- 0,
- GTK_PARAM_READWRITE));
-
- /**
- * GtkRadioAction:group:
- *
- * Sets a new group for a radio action.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_GROUP,
- g_param_spec_object ("group",
- P_("Group"),
- P_("The radio action whose group this action belongs to."),
- GTK_TYPE_RADIO_ACTION,
- GTK_PARAM_WRITABLE));
-
- /**
- * GtkRadioAction:current-value:
- *
- * The value property of the currently active member of the group to which
- * this action belongs.
- *
- * Since: 2.10
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_CURRENT_VALUE,
- g_param_spec_int ("current-value",
- P_("The current value"),
- P_("The value property of the currently active member of the group to which this action belongs."),
- G_MININT,
- G_MAXINT,
- 0,
- GTK_PARAM_READWRITE));
-
- /**
- * GtkRadioAction::changed:
- * @action: the action on which the signal is emitted
- * @current: the member of @action<!-- -->s group which has just been activated
- *
- * The ::changed signal is emitted on every member of a radio group when the
- * active member is changed. The signal gets emitted after the ::activate signals
- * for the previous and current active members.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
- radio_action_signals[CHANGED] =
- g_signal_new (I_("changed"),
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
- G_STRUCT_OFFSET (GtkRadioActionClass, changed), NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, GTK_TYPE_RADIO_ACTION);
-}
-
-static void
-gtk_radio_action_init (GtkRadioAction *action)
-{
- action->private_data = gtk_radio_action_get_instance_private (action);
- action->private_data->group = g_slist_prepend (NULL, action);
- action->private_data->value = 0;
-
- gtk_toggle_action_set_draw_as_radio (GTK_TOGGLE_ACTION (action), TRUE);
-}
-
-/**
- * gtk_radio_action_new:
- * @name: A unique name for the action
- * @label: (allow-none): The label displayed in menu items and on buttons,
- * or %NULL
- * @tooltip: (allow-none): A tooltip for this action, or %NULL
- * @stock_id: (allow-none): The stock icon to display in widgets representing
- * this action, or %NULL
- * @value: The value which gtk_radio_action_get_current_value() should
- * return if this action is selected.
- *
- * Creates a new #GtkRadioAction object. To add the action to
- * a #GtkActionGroup and set the accelerator for the action,
- * call gtk_action_group_add_action_with_accel().
- *
- * Return value: a new #GtkRadioAction
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-GtkRadioAction *
-gtk_radio_action_new (const gchar *name,
- const gchar *label,
- const gchar *tooltip,
- const gchar *stock_id,
- gint value)
-{
- g_return_val_if_fail (name != NULL, NULL);
-
- return g_object_new (GTK_TYPE_RADIO_ACTION,
- "name", name,
- "label", label,
- "tooltip", tooltip,
- "stock-id", stock_id,
- "value", value,
- NULL);
-}
-
-static void
-gtk_radio_action_finalize (GObject *object)
-{
- GtkRadioAction *action;
- GSList *tmp_list;
-
- action = GTK_RADIO_ACTION (object);
-
- action->private_data->group = g_slist_remove (action->private_data->group, action);
-
- tmp_list = action->private_data->group;
-
- while (tmp_list)
- {
- GtkRadioAction *tmp_action = tmp_list->data;
-
- tmp_list = tmp_list->next;
- tmp_action->private_data->group = action->private_data->group;
- }
-
- G_OBJECT_CLASS (gtk_radio_action_parent_class)->finalize (object);
-}
-
-static void
-gtk_radio_action_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GtkRadioAction *radio_action;
-
- radio_action = GTK_RADIO_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_VALUE:
- radio_action->private_data->value = g_value_get_int (value);
- break;
- case PROP_GROUP:
- {
- GtkRadioAction *arg;
- GSList *slist = NULL;
-
- if (G_VALUE_HOLDS_OBJECT (value))
- {
- arg = GTK_RADIO_ACTION (g_value_get_object (value));
- if (arg)
- slist = gtk_radio_action_get_group (arg);
- gtk_radio_action_set_group (radio_action, slist);
- }
- }
- break;
- case PROP_CURRENT_VALUE:
- gtk_radio_action_set_current_value (radio_action,
- g_value_get_int (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gtk_radio_action_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GtkRadioAction *radio_action;
-
- radio_action = GTK_RADIO_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_VALUE:
- g_value_set_int (value, radio_action->private_data->value);
- break;
- case PROP_CURRENT_VALUE:
- g_value_set_int (value,
- gtk_radio_action_get_current_value (radio_action));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gtk_radio_action_activate (GtkAction *action)
-{
- GtkRadioAction *radio_action;
- GtkToggleAction *toggle_action;
- GtkToggleAction *tmp_action;
- GSList *tmp_list;
- gboolean active;
-
- radio_action = GTK_RADIO_ACTION (action);
- toggle_action = GTK_TOGGLE_ACTION (action);
-
- active = gtk_toggle_action_get_active (toggle_action);
- if (active)
- {
- tmp_list = radio_action->private_data->group;
-
- while (tmp_list)
- {
- tmp_action = tmp_list->data;
- tmp_list = tmp_list->next;
-
- if (gtk_toggle_action_get_active (tmp_action) &&
- (tmp_action != toggle_action))
- {
- _gtk_toggle_action_set_active (toggle_action, !active);
-
- break;
- }
- }
- g_object_notify (G_OBJECT (action), "active");
- }
- else
- {
- _gtk_toggle_action_set_active (toggle_action, !active);
- g_object_notify (G_OBJECT (action), "active");
-
- tmp_list = radio_action->private_data->group;
- while (tmp_list)
- {
- tmp_action = tmp_list->data;
- tmp_list = tmp_list->next;
-
- if (gtk_toggle_action_get_active (tmp_action) &&
- (tmp_action != toggle_action))
- {
- _gtk_action_emit_activate (GTK_ACTION (tmp_action));
- break;
- }
- }
-
- tmp_list = radio_action->private_data->group;
- while (tmp_list)
- {
- tmp_action = tmp_list->data;
- tmp_list = tmp_list->next;
-
- g_object_notify (G_OBJECT (tmp_action), "current-value");
-
- g_signal_emit (tmp_action, radio_action_signals[CHANGED], 0, radio_action);
- }
- }
-
- gtk_toggle_action_toggled (toggle_action);
-}
-
-static GtkWidget *
-create_menu_item (GtkAction *action)
-{
- return g_object_new (GTK_TYPE_CHECK_MENU_ITEM,
- "draw-as-radio", TRUE,
- NULL);
-}
-
-/**
- * gtk_radio_action_get_group:
- * @action: the action object
- *
- * Returns the list representing the radio group for this object.
- * Note that the returned list is only valid until the next change
- * to the group.
- *
- * A common way to set up a group of radio group is the following:
- * |[
- * GSList *group = NULL;
- * GtkRadioAction *action;
- *
- * while (/* more actions to add */)
- * {
- * action = gtk_radio_action_new (...);
- *
- * gtk_radio_action_set_group (action, group);
- * group = gtk_radio_action_get_group (action);
- * }
- * ]|
- *
- * Returns: (element-type GtkRadioAction) (transfer none): the list representing the radio group for this object
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-GSList *
-gtk_radio_action_get_group (GtkRadioAction *action)
-{
- g_return_val_if_fail (GTK_IS_RADIO_ACTION (action), NULL);
-
- return action->private_data->group;
-}
-
-/**
- * gtk_radio_action_set_group:
- * @action: the action object
- * @group: (element-type GtkRadioAction): a list representing a radio group
- *
- * Sets the radio group for the radio action object.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-void
-gtk_radio_action_set_group (GtkRadioAction *action,
- GSList *group)
-{
- g_return_if_fail (GTK_IS_RADIO_ACTION (action));
- g_return_if_fail (!g_slist_find (group, action));
-
- if (action->private_data->group)
- {
- GSList *slist;
-
- action->private_data->group = g_slist_remove (action->private_data->group, action);
-
- for (slist = action->private_data->group; slist; slist = slist->next)
- {
- GtkRadioAction *tmp_action = slist->data;
-
- tmp_action->private_data->group = action->private_data->group;
- }
- }
-
- action->private_data->group = g_slist_prepend (group, action);
-
- if (group)
- {
- GSList *slist;
-
- for (slist = action->private_data->group; slist; slist = slist->next)
- {
- GtkRadioAction *tmp_action = slist->data;
-
- tmp_action->private_data->group = action->private_data->group;
- }
- }
- else
- {
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
- }
-}
-
-/**
- * gtk_radio_action_join_group:
- * @action: the action object
- * @group_source: (allow-none): a radio action object whos group we are
- * joining, or %NULL to remove the radio action from its group
- *
- * Joins a radio action object to the group of another radio action object.
- *
- * Use this in language bindings instead of the gtk_radio_action_get_group()
- * and gtk_radio_action_set_group() methods
- *
- * A common way to set up a group of radio actions is the following:
- * |[
- * GtkRadioAction *action;
- * GtkRadioAction *last_action;
- *
- * while (/* more actions to add */)
- * {
- * action = gtk_radio_action_new (...);
- *
- * gtk_radio_action_join_group (action, last_action);
- * last_action = action;
- * }
- * ]|
- *
- * Since: 3.0
- *
- * Deprecated: 3.10
- */
-void
-gtk_radio_action_join_group (GtkRadioAction *action,
- GtkRadioAction *group_source)
-{
- g_return_if_fail (GTK_IS_RADIO_ACTION (action));
- g_return_if_fail (group_source == NULL || GTK_IS_RADIO_ACTION (group_source));
-
- if (group_source)
- {
- GSList *group;
- group = gtk_radio_action_get_group (group_source);
-
- if (!group)
- {
- /* if we are not already part of a group we need to set up a new one
- and then get the newly created group */
- gtk_radio_action_set_group (group_source, NULL);
- group = gtk_radio_action_get_group (group_source);
- }
-
- gtk_radio_action_set_group (action, group);
- }
- else
- {
- gtk_radio_action_set_group (action, NULL);
- }
-}
-
-/**
- * gtk_radio_action_get_current_value:
- * @action: a #GtkRadioAction
- *
- * Obtains the value property of the currently active member of
- * the group to which @action belongs.
- *
- * Return value: The value of the currently active group member
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-gint
-gtk_radio_action_get_current_value (GtkRadioAction *action)
-{
- GSList *slist;
-
- g_return_val_if_fail (GTK_IS_RADIO_ACTION (action), 0);
-
- if (action->private_data->group)
- {
- for (slist = action->private_data->group; slist; slist = slist->next)
- {
- GtkToggleAction *toggle_action = slist->data;
-
- if (gtk_toggle_action_get_active (toggle_action))
- return GTK_RADIO_ACTION (toggle_action)->private_data->value;
- }
- }
-
- return action->private_data->value;
-}
-
-/**
- * gtk_radio_action_set_current_value:
- * @action: a #GtkRadioAction
- * @current_value: the new value
- *
- * Sets the currently active group member to the member with value
- * property @current_value.
- *
- * Since: 2.10
- *
- * Deprecated: 3.10
- **/
-void
-gtk_radio_action_set_current_value (GtkRadioAction *action,
- gint current_value)
-{
- GSList *slist;
-
- g_return_if_fail (GTK_IS_RADIO_ACTION (action));
-
- if (action->private_data->group)
- {
- for (slist = action->private_data->group; slist; slist = slist->next)
- {
- GtkRadioAction *radio_action = slist->data;
-
- if (radio_action->private_data->value == current_value)
- {
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (radio_action),
- TRUE);
- return;
- }
- }
- }
-
- if (action->private_data->value == current_value)
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
- else
- g_warning ("Radio group does not contain an action with value '%d'",
- current_value);
-}
+++ /dev/null
-/*
- * GTK - The GIMP Toolkit
- * Copyright (C) 1998, 1999 Red Hat, Inc.
- * All rights reserved.
- *
- * This Library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This Library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Author: James Henstridge <james@daa.com.au>
- *
- * Modified by the GTK+ Team and others 2003. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#ifndef __GTK_RADIO_ACTION_H__
-#define __GTK_RADIO_ACTION_H__
-
-#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
-#error "Only <gtk/gtk.h> can be included directly."
-#endif
-
-#include <gtk/gtktoggleaction.h>
-
-G_BEGIN_DECLS
-
-#define GTK_TYPE_RADIO_ACTION (gtk_radio_action_get_type ())
-#define GTK_RADIO_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RADIO_ACTION, GtkRadioAction))
-#define GTK_RADIO_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_RADIO_ACTION, GtkRadioActionClass))
-#define GTK_IS_RADIO_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RADIO_ACTION))
-#define GTK_IS_RADIO_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RADIO_ACTION))
-#define GTK_RADIO_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_RADIO_ACTION, GtkRadioActionClass))
-
-typedef struct _GtkRadioAction GtkRadioAction;
-typedef struct _GtkRadioActionPrivate GtkRadioActionPrivate;
-typedef struct _GtkRadioActionClass GtkRadioActionClass;
-
-struct _GtkRadioAction
-{
- GtkToggleAction parent;
-
- /*< private >*/
- GtkRadioActionPrivate *private_data;
-};
-
-struct _GtkRadioActionClass
-{
- GtkToggleActionClass parent_class;
-
- void (* changed) (GtkRadioAction *action, GtkRadioAction *current);
-
- /* Padding for future expansion */
- void (*_gtk_reserved1) (void);
- void (*_gtk_reserved2) (void);
- void (*_gtk_reserved3) (void);
- void (*_gtk_reserved4) (void);
-};
-
-GDK_DEPRECATED_IN_3_10
-GType gtk_radio_action_get_type (void) G_GNUC_CONST;
-GDK_DEPRECATED_IN_3_10
-GtkRadioAction *gtk_radio_action_new (const gchar *name,
- const gchar *label,
- const gchar *tooltip,
- const gchar *stock_id,
- gint value);
-GDK_DEPRECATED_IN_3_10
-GSList *gtk_radio_action_get_group (GtkRadioAction *action);
-GDK_DEPRECATED_IN_3_10
-void gtk_radio_action_set_group (GtkRadioAction *action,
- GSList *group);
-GDK_DEPRECATED_IN_3_10
-void gtk_radio_action_join_group (GtkRadioAction *action,
- GtkRadioAction *group_source);
-GDK_DEPRECATED_IN_3_10
-gint gtk_radio_action_get_current_value (GtkRadioAction *action);
-GDK_DEPRECATED_IN_3_10
-void gtk_radio_action_set_current_value (GtkRadioAction *action,
- gint current_value);
-
-G_END_DECLS
-
-#endif /* __GTK_RADIO_ACTION_H__ */
#include "gtkaccellabel.h"
#include "gtkmarshalers.h"
#include "gtkradiomenuitem.h"
-#include "gtkactivatable.h"
+#include "deprecated/gtkactivatable.h"
#include "gtkprivate.h"
#include "gtkintl.h"
#include "a11y/gtkradiomenuitemaccessible.h"
+++ /dev/null
-/* GTK - The GIMP Toolkit
- * Recent chooser action for GtkUIManager
- *
- * Copyright (C) 2007, Emmanuele Bassi
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-
-#define GDK_DISABLE_DEPRECATION_WARNINGS
-
-#include "gtkintl.h"
-#include "gtkrecentaction.h"
-#include "gtkimagemenuitem.h"
-#include "gtkmenutoolbutton.h"
-#include "gtkrecentchooser.h"
-#include "gtkrecentchoosermenu.h"
-#include "gtkrecentchooserutils.h"
-#include "gtkrecentchooserprivate.h"
-#include "gtkprivate.h"
-
-/**
- * SECTION:gtkrecentaction
- * @Short_description: An action of which represents a list of recently used files
- * @Title: GtkRecentAction
- *
- * A #GtkRecentAction represents a list of recently used files, which
- * can be shown by widgets such as #GtkRecentChooserDialog or
- * #GtkRecentChooserMenu.
- *
- * To construct a submenu showing recently used files, use a #GtkRecentAction
- * as the action for a <menuitem>. To construct a menu toolbutton showing
- * the recently used files in the popup menu, use a #GtkRecentAction as the
- * action for a <toolitem> element.
- */
-
-
-#define FALLBACK_ITEM_LIMIT 10
-
-
-struct _GtkRecentActionPrivate
-{
- GtkRecentManager *manager;
-
- guint show_numbers : 1;
-
- /* RecentChooser properties */
- guint show_private : 1;
- guint show_not_found : 1;
- guint show_tips : 1;
- guint show_icons : 1;
- guint local_only : 1;
-
- gint limit;
-
- GtkRecentSortType sort_type;
- GtkRecentSortFunc sort_func;
- gpointer sort_data;
- GDestroyNotify data_destroy;
-
- GtkRecentFilter *current_filter;
-
- GSList *choosers;
- GtkRecentChooser *current_chooser;
-};
-
-enum
-{
- PROP_0,
-
- PROP_SHOW_NUMBERS
-};
-
-static void gtk_recent_chooser_iface_init (GtkRecentChooserIface *iface);
-
-G_DEFINE_TYPE_WITH_CODE (GtkRecentAction,
- gtk_recent_action,
- GTK_TYPE_ACTION,
- G_ADD_PRIVATE (GtkRecentAction)
- G_IMPLEMENT_INTERFACE (GTK_TYPE_RECENT_CHOOSER,
- gtk_recent_chooser_iface_init));
-
-static gboolean
-gtk_recent_action_set_current_uri (GtkRecentChooser *chooser,
- const gchar *uri,
- GError **error)
-{
- GtkRecentAction *action = GTK_RECENT_ACTION (chooser);
- GtkRecentActionPrivate *priv = action->priv;
- GSList *l;
-
- for (l = priv->choosers; l; l = l->next)
- {
- GtkRecentChooser *recent_chooser = l->data;
-
- if (!gtk_recent_chooser_set_current_uri (recent_chooser, uri, error))
- return FALSE;
- }
-
- return TRUE;
-}
-
-static gchar *
-gtk_recent_action_get_current_uri (GtkRecentChooser *chooser)
-{
- GtkRecentAction *recent_action = GTK_RECENT_ACTION (chooser);
- GtkRecentActionPrivate *priv = recent_action->priv;
-
- if (priv->current_chooser)
- return gtk_recent_chooser_get_current_uri (priv->current_chooser);
-
- return NULL;
-}
-
-static gboolean
-gtk_recent_action_select_uri (GtkRecentChooser *chooser,
- const gchar *uri,
- GError **error)
-{
- GtkRecentAction *action = GTK_RECENT_ACTION (chooser);
- GtkRecentActionPrivate *priv = action->priv;
- GSList *l;
-
- for (l = priv->choosers; l; l = l->next)
- {
- GtkRecentChooser *recent_chooser = l->data;
-
- if (!gtk_recent_chooser_select_uri (recent_chooser, uri, error))
- return FALSE;
- }
-
- return TRUE;
-}
-
-static void
-gtk_recent_action_unselect_uri (GtkRecentChooser *chooser,
- const gchar *uri)
-{
- GtkRecentAction *action = GTK_RECENT_ACTION (chooser);
- GtkRecentActionPrivate *priv = action->priv;
- GSList *l;
-
- for (l = priv->choosers; l; l = l->next)
- {
- GtkRecentChooser *chooser = l->data;
-
- gtk_recent_chooser_unselect_uri (chooser, uri);
- }
-}
-
-static void
-gtk_recent_action_select_all (GtkRecentChooser *chooser)
-{
- g_warning ("This function is not implemented for "
- "widgets of class '%s'",
- g_type_name (G_OBJECT_TYPE (chooser)));
-}
-
-static void
-gtk_recent_action_unselect_all (GtkRecentChooser *chooser)
-{
- g_warning ("This function is not implemented for "
- "widgets of class '%s'",
- g_type_name (G_OBJECT_TYPE (chooser)));
-}
-
-
-static GList *
-gtk_recent_action_get_items (GtkRecentChooser *chooser)
-{
- GtkRecentAction *action = GTK_RECENT_ACTION (chooser);
- GtkRecentActionPrivate *priv = action->priv;
-
- return _gtk_recent_chooser_get_items (chooser,
- priv->current_filter,
- priv->sort_func,
- priv->sort_data);
-}
-
-static GtkRecentManager *
-gtk_recent_action_get_recent_manager (GtkRecentChooser *chooser)
-{
- return GTK_RECENT_ACTION (chooser)->priv->manager;
-}
-
-static void
-gtk_recent_action_set_sort_func (GtkRecentChooser *chooser,
- GtkRecentSortFunc sort_func,
- gpointer sort_data,
- GDestroyNotify data_destroy)
-{
- GtkRecentAction *action = GTK_RECENT_ACTION (chooser);
- GtkRecentActionPrivate *priv = action->priv;
- GSList *l;
-
- if (priv->data_destroy)
- {
- priv->data_destroy (priv->sort_data);
- priv->data_destroy = NULL;
- }
-
- priv->sort_func = NULL;
- priv->sort_data = NULL;
-
- if (sort_func)
- {
- priv->sort_func = sort_func;
- priv->sort_data = sort_data;
- priv->data_destroy = data_destroy;
- }
-
- for (l = priv->choosers; l; l = l->next)
- {
- GtkRecentChooser *chooser_menu = l->data;
-
- gtk_recent_chooser_set_sort_func (chooser_menu, priv->sort_func,
- priv->sort_data,
- priv->data_destroy);
- }
-}
-
-static void
-set_current_filter (GtkRecentAction *action,
- GtkRecentFilter *filter)
-{
- GtkRecentActionPrivate *priv = action->priv;
-
- g_object_ref (action);
-
- if (priv->current_filter)
- g_object_unref (priv->current_filter);
-
- priv->current_filter = filter;
-
- if (priv->current_filter)
- g_object_ref_sink (priv->current_filter);
-
- g_object_notify (G_OBJECT (action), "filter");
-
- g_object_unref (action);
-}
-
-static void
-gtk_recent_action_add_filter (GtkRecentChooser *chooser,
- GtkRecentFilter *filter)
-{
- GtkRecentAction *action = GTK_RECENT_ACTION (chooser);
- GtkRecentActionPrivate *priv = action->priv;
-
- if (priv->current_filter != filter)
- set_current_filter (GTK_RECENT_ACTION (chooser), filter);
-}
-
-static void
-gtk_recent_action_remove_filter (GtkRecentChooser *chooser,
- GtkRecentFilter *filter)
-{
- GtkRecentAction *action = GTK_RECENT_ACTION (chooser);
- GtkRecentActionPrivate *priv = action->priv;
-
- if (priv->current_filter == filter)
- set_current_filter (GTK_RECENT_ACTION (chooser), NULL);
-}
-
-static GSList *
-gtk_recent_action_list_filters (GtkRecentChooser *chooser)
-{
- GtkRecentAction *action = GTK_RECENT_ACTION (chooser);
- GtkRecentActionPrivate *priv = action->priv;
- GSList *retval = NULL;
- GtkRecentFilter *current_filter;
-
- current_filter = priv->current_filter;
- retval = g_slist_prepend (retval, current_filter);
-
- return retval;
-}
-
-
-static void
-gtk_recent_chooser_iface_init (GtkRecentChooserIface *iface)
-{
- iface->set_current_uri = gtk_recent_action_set_current_uri;
- iface->get_current_uri = gtk_recent_action_get_current_uri;
- iface->select_uri = gtk_recent_action_select_uri;
- iface->unselect_uri = gtk_recent_action_unselect_uri;
- iface->select_all = gtk_recent_action_select_all;
- iface->unselect_all = gtk_recent_action_unselect_all;
- iface->get_items = gtk_recent_action_get_items;
- iface->get_recent_manager = gtk_recent_action_get_recent_manager;
- iface->set_sort_func = gtk_recent_action_set_sort_func;
- iface->add_filter = gtk_recent_action_add_filter;
- iface->remove_filter = gtk_recent_action_remove_filter;
- iface->list_filters = gtk_recent_action_list_filters;
-}
-
-static void
-gtk_recent_action_activate (GtkAction *action)
-{
- GtkRecentAction *recent_action = GTK_RECENT_ACTION (action);
- GtkRecentActionPrivate *priv = recent_action->priv;
-
- /* we have probably been invoked by a menu tool button or by a
- * direct call of gtk_action_activate(); since no item has been
- * selected, we must unset the current recent chooser pointer
- */
- priv->current_chooser = NULL;
-}
-
-static void
-delegate_selection_changed (GtkRecentAction *action,
- GtkRecentChooser *chooser)
-{
- GtkRecentActionPrivate *priv = action->priv;
-
- priv->current_chooser = chooser;
-
- g_signal_emit_by_name (action, "selection-changed");
-}
-
-static void
-delegate_item_activated (GtkRecentAction *action,
- GtkRecentChooser *chooser)
-{
- GtkRecentActionPrivate *priv = action->priv;
-
- priv->current_chooser = chooser;
-
- g_signal_emit_by_name (action, "item-activated");
-}
-
-static void
-gtk_recent_action_connect_proxy (GtkAction *action,
- GtkWidget *widget)
-{
- GtkRecentAction *recent_action = GTK_RECENT_ACTION (action);
- GtkRecentActionPrivate *priv = recent_action->priv;
-
- /* it can only be a recent chooser implementor anyway... */
- if (GTK_IS_RECENT_CHOOSER (widget) &&
- !g_slist_find (priv->choosers, widget))
- {
- if (priv->sort_func)
- {
- gtk_recent_chooser_set_sort_func (GTK_RECENT_CHOOSER (widget),
- priv->sort_func,
- priv->sort_data,
- priv->data_destroy);
- }
-
- g_signal_connect_swapped (widget, "selection_changed",
- G_CALLBACK (delegate_selection_changed),
- action);
- g_signal_connect_swapped (widget, "item-activated",
- G_CALLBACK (delegate_item_activated),
- action);
- }
-
- if (GTK_ACTION_CLASS (gtk_recent_action_parent_class)->connect_proxy)
- GTK_ACTION_CLASS (gtk_recent_action_parent_class)->connect_proxy (action, widget);
-}
-
-static void
-gtk_recent_action_disconnect_proxy (GtkAction *action,
- GtkWidget *widget)
-{
- GtkRecentAction *recent_action = GTK_RECENT_ACTION (action);
- GtkRecentActionPrivate *priv = recent_action->priv;
-
- /* if it was one of the recent choosers we created, remove it
- * from the list
- */
- if (g_slist_find (priv->choosers, widget))
- priv->choosers = g_slist_remove (priv->choosers, widget);
-
- if (GTK_ACTION_CLASS (gtk_recent_action_parent_class)->disconnect_proxy)
- GTK_ACTION_CLASS (gtk_recent_action_parent_class)->disconnect_proxy (action, widget);
-}
-
-static GtkWidget *
-gtk_recent_action_create_menu (GtkAction *action)
-{
- GtkRecentAction *recent_action = GTK_RECENT_ACTION (action);
- GtkRecentActionPrivate *priv = recent_action->priv;
- GtkWidget *widget;
-
- widget = g_object_new (GTK_TYPE_RECENT_CHOOSER_MENU,
- "show-private", priv->show_private,
- "show-not-found", priv->show_not_found,
- "show-tips", priv->show_tips,
- "show-icons", priv->show_icons,
- "show-numbers", priv->show_numbers,
- "limit", priv->limit,
- "sort-type", priv->sort_type,
- "recent-manager", priv->manager,
- "filter", priv->current_filter,
- "local-only", priv->local_only,
- NULL);
-
- if (priv->sort_func)
- {
- gtk_recent_chooser_set_sort_func (GTK_RECENT_CHOOSER (widget),
- priv->sort_func,
- priv->sort_data,
- priv->data_destroy);
- }
-
- g_signal_connect_swapped (widget, "selection_changed",
- G_CALLBACK (delegate_selection_changed),
- recent_action);
- g_signal_connect_swapped (widget, "item-activated",
- G_CALLBACK (delegate_item_activated),
- recent_action);
-
- /* keep track of the choosers we create */
- priv->choosers = g_slist_prepend (priv->choosers, widget);
-
- return widget;
-}
-
-static GtkWidget *
-gtk_recent_action_create_menu_item (GtkAction *action)
-{
- GtkWidget *menu;
- GtkWidget *menuitem;
-
- menu = gtk_recent_action_create_menu (action);
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- menuitem = g_object_new (GTK_TYPE_IMAGE_MENU_ITEM, NULL);
- G_GNUC_END_IGNORE_DEPRECATIONS;
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
- gtk_widget_show (menu);
-
- return menuitem;
-}
-
-static GtkWidget *
-gtk_recent_action_create_tool_item (GtkAction *action)
-{
- GtkWidget *menu;
- GtkWidget *toolitem;
-
- menu = gtk_recent_action_create_menu (action);
- toolitem = g_object_new (GTK_TYPE_MENU_TOOL_BUTTON, NULL);
- gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (toolitem), menu);
- gtk_widget_show (menu);
-
- return toolitem;
-}
-
-static void
-set_recent_manager (GtkRecentAction *action,
- GtkRecentManager *manager)
-{
- GtkRecentActionPrivate *priv = action->priv;
-
- if (manager)
- priv->manager = NULL;
- else
- priv->manager = gtk_recent_manager_get_default ();
-}
-
-static void
-gtk_recent_action_finalize (GObject *gobject)
-{
- GtkRecentAction *action = GTK_RECENT_ACTION (gobject);
- GtkRecentActionPrivate *priv = action->priv;
-
- priv->manager = NULL;
-
- if (priv->data_destroy)
- {
- priv->data_destroy (priv->sort_data);
- priv->data_destroy = NULL;
- }
-
- priv->sort_data = NULL;
- priv->sort_func = NULL;
-
- g_slist_free (priv->choosers);
-
- G_OBJECT_CLASS (gtk_recent_action_parent_class)->finalize (gobject);
-}
-
-static void
-gtk_recent_action_dispose (GObject *gobject)
-{
- GtkRecentAction *action = GTK_RECENT_ACTION (gobject);
- GtkRecentActionPrivate *priv = action->priv;
-
- if (priv->current_filter)
- {
- g_object_unref (priv->current_filter);
- priv->current_filter = NULL;
- }
-
- G_OBJECT_CLASS (gtk_recent_action_parent_class)->dispose (gobject);
-}
-
-static void
-gtk_recent_action_set_property (GObject *gobject,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GtkRecentAction *action = GTK_RECENT_ACTION (gobject);
- GtkRecentActionPrivate *priv = action->priv;
-
- switch (prop_id)
- {
- case PROP_SHOW_NUMBERS:
- priv->show_numbers = g_value_get_boolean (value);
- break;
- case GTK_RECENT_CHOOSER_PROP_SHOW_PRIVATE:
- priv->show_private = g_value_get_boolean (value);
- break;
- case GTK_RECENT_CHOOSER_PROP_SHOW_NOT_FOUND:
- priv->show_not_found = g_value_get_boolean (value);
- break;
- case GTK_RECENT_CHOOSER_PROP_SHOW_TIPS:
- priv->show_tips = g_value_get_boolean (value);
- break;
- case GTK_RECENT_CHOOSER_PROP_SHOW_ICONS:
- priv->show_icons = g_value_get_boolean (value);
- break;
- case GTK_RECENT_CHOOSER_PROP_LIMIT:
- priv->limit = g_value_get_int (value);
- break;
- case GTK_RECENT_CHOOSER_PROP_LOCAL_ONLY:
- priv->local_only = g_value_get_boolean (value);
- break;
- case GTK_RECENT_CHOOSER_PROP_SORT_TYPE:
- priv->sort_type = g_value_get_enum (value);
- break;
- case GTK_RECENT_CHOOSER_PROP_FILTER:
- set_current_filter (action, g_value_get_object (value));
- break;
- case GTK_RECENT_CHOOSER_PROP_SELECT_MULTIPLE:
- g_warning ("%s: Choosers of type `%s' do not support selecting multiple items.",
- G_STRFUNC,
- G_OBJECT_TYPE_NAME (gobject));
- return;
- case GTK_RECENT_CHOOSER_PROP_RECENT_MANAGER:
- set_recent_manager (action, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
- return;
- }
-}
-
-static void
-gtk_recent_action_get_property (GObject *gobject,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GtkRecentAction *action = GTK_RECENT_ACTION (gobject);
- GtkRecentActionPrivate *priv = action->priv;
-
- switch (prop_id)
- {
- case PROP_SHOW_NUMBERS:
- g_value_set_boolean (value, priv->show_numbers);
- break;
- case GTK_RECENT_CHOOSER_PROP_SHOW_PRIVATE:
- g_value_set_boolean (value, priv->show_private);
- break;
- case GTK_RECENT_CHOOSER_PROP_SHOW_NOT_FOUND:
- g_value_set_boolean (value, priv->show_not_found);
- break;
- case GTK_RECENT_CHOOSER_PROP_SHOW_TIPS:
- g_value_set_boolean (value, priv->show_tips);
- break;
- case GTK_RECENT_CHOOSER_PROP_SHOW_ICONS:
- g_value_set_boolean (value, priv->show_icons);
- break;
- case GTK_RECENT_CHOOSER_PROP_LIMIT:
- g_value_set_int (value, priv->limit);
- break;
- case GTK_RECENT_CHOOSER_PROP_LOCAL_ONLY:
- g_value_set_boolean (value, priv->local_only);
- break;
- case GTK_RECENT_CHOOSER_PROP_SORT_TYPE:
- g_value_set_enum (value, priv->sort_type);
- break;
- case GTK_RECENT_CHOOSER_PROP_FILTER:
- g_value_set_object (value, priv->current_filter);
- break;
- case GTK_RECENT_CHOOSER_PROP_SELECT_MULTIPLE:
- g_value_set_boolean (value, FALSE);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
- break;
- }
-}
-
-static void
-gtk_recent_action_class_init (GtkRecentActionClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GtkActionClass *action_class = GTK_ACTION_CLASS (klass);
-
- gobject_class->finalize = gtk_recent_action_finalize;
- gobject_class->dispose = gtk_recent_action_dispose;
- gobject_class->set_property = gtk_recent_action_set_property;
- gobject_class->get_property = gtk_recent_action_get_property;
-
- action_class->activate = gtk_recent_action_activate;
- action_class->connect_proxy = gtk_recent_action_connect_proxy;
- action_class->disconnect_proxy = gtk_recent_action_disconnect_proxy;
- action_class->create_menu_item = gtk_recent_action_create_menu_item;
- action_class->create_tool_item = gtk_recent_action_create_tool_item;
- action_class->create_menu = gtk_recent_action_create_menu;
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- action_class->menu_item_type = GTK_TYPE_IMAGE_MENU_ITEM;
- G_GNUC_END_IGNORE_DEPRECATIONS;
- action_class->toolbar_item_type = GTK_TYPE_MENU_TOOL_BUTTON;
-
- _gtk_recent_chooser_install_properties (gobject_class);
-
- /**
- * GtkRecentAction:show-numbers:
- *
- * Whether the items should be displayed with a number.
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_SHOW_NUMBERS,
- g_param_spec_boolean ("show-numbers",
- P_("Show Numbers"),
- P_("Whether the items should be displayed with a number"),
- FALSE,
- G_PARAM_READWRITE));
-
-}
-
-static void
-gtk_recent_action_init (GtkRecentAction *action)
-{
- GtkRecentActionPrivate *priv;
-
- action->priv = priv = gtk_recent_action_get_instance_private (action);
-
- priv->show_numbers = FALSE;
- priv->show_icons = TRUE;
- priv->show_tips = FALSE;
- priv->show_not_found = TRUE;
- priv->show_private = FALSE;
- priv->local_only = TRUE;
-
- priv->limit = FALLBACK_ITEM_LIMIT;
-
- priv->sort_type = GTK_RECENT_SORT_NONE;
- priv->sort_func = NULL;
- priv->sort_data = NULL;
- priv->data_destroy = NULL;
-
- priv->current_filter = NULL;
-
- priv->manager = NULL;
-}
-
-/**
- * gtk_recent_action_new:
- * @name: a unique name for the action
- * @label: (allow-none): the label displayed in menu items and on buttons,
- * or %NULL
- * @tooltip: (allow-none): a tooltip for the action, or %NULL
- * @stock_id: (allow-none): the stock icon to display in widgets representing
- * the action, or %NULL
- *
- * Creates a new #GtkRecentAction object. To add the action to
- * a #GtkActionGroup and set the accelerator for the action,
- * call gtk_action_group_add_action_with_accel().
- *
- * Return value: the newly created #GtkRecentAction.
- *
- * Since: 2.12
- *
- * Deprecated: 3.10
- */
-GtkAction *
-gtk_recent_action_new (const gchar *name,
- const gchar *label,
- const gchar *tooltip,
- const gchar *stock_id)
-{
- g_return_val_if_fail (name != NULL, NULL);
-
- return g_object_new (GTK_TYPE_RECENT_ACTION,
- "name", name,
- "label", label,
- "tooltip", tooltip,
- "stock-id", stock_id,
- NULL);
-}
-
-/**
- * gtk_recent_action_new_for_manager:
- * @name: a unique name for the action
- * @label: (allow-none): the label displayed in menu items and on buttons,
- * or %NULL
- * @tooltip: (allow-none): a tooltip for the action, or %NULL
- * @stock_id: (allow-none): the stock icon to display in widgets representing
- * the action, or %NULL
- * @manager: (allow-none): a #GtkRecentManager, or %NULL for using the default
- * #GtkRecentManager
- *
- * Creates a new #GtkRecentAction object. To add the action to
- * a #GtkActionGroup and set the accelerator for the action,
- * call gtk_action_group_add_action_with_accel().
- *
- * Return value: the newly created #GtkRecentAction
- *
- * Since: 2.12
- *
- * Deprecated: 3.10
- */
-GtkAction *
-gtk_recent_action_new_for_manager (const gchar *name,
- const gchar *label,
- const gchar *tooltip,
- const gchar *stock_id,
- GtkRecentManager *manager)
-{
- g_return_val_if_fail (name != NULL, NULL);
- g_return_val_if_fail (manager == NULL || GTK_IS_RECENT_MANAGER (manager), NULL);
-
- return g_object_new (GTK_TYPE_RECENT_ACTION,
- "name", name,
- "label", label,
- "tooltip", tooltip,
- "stock-id", stock_id,
- "recent-manager", manager,
- NULL);
-}
-
-/**
- * gtk_recent_action_get_show_numbers:
- * @action: a #GtkRecentAction
- *
- * Returns the value set by gtk_recent_chooser_menu_set_show_numbers().
- *
- * Return value: %TRUE if numbers should be shown.
- *
- * Since: 2.12
- *
- * Deprecated: 3.10
- */
-gboolean
-gtk_recent_action_get_show_numbers (GtkRecentAction *action)
-{
- g_return_val_if_fail (GTK_IS_RECENT_ACTION (action), FALSE);
-
- return action->priv->show_numbers;
-}
-
-/**
- * gtk_recent_action_set_show_numbers:
- * @action: a #GtkRecentAction
- * @show_numbers: %TRUE if the shown items should be numbered
- *
- * Sets whether a number should be added to the items shown by the
- * widgets representing @action. The numbers are shown to provide
- * a unique character for a mnemonic to be used inside the menu item's
- * label. Only the first ten items get a number to avoid clashes.
- *
- * Since: 2.12
- *
- * Deprecated: 3.10
- */
-void
-gtk_recent_action_set_show_numbers (GtkRecentAction *action,
- gboolean show_numbers)
-{
- GtkRecentActionPrivate *priv;
-
- g_return_if_fail (GTK_IS_RECENT_ACTION (action));
-
- priv = action->priv;
-
- if (priv->show_numbers != show_numbers)
- {
- g_object_ref (action);
-
- priv->show_numbers = show_numbers;
-
- g_object_notify (G_OBJECT (action), "show-numbers");
- g_object_unref (action);
- }
-}
+++ /dev/null
-/* GTK - The GIMP Toolkit
- * Recent chooser action for GtkUIManager
- *
- * Copyright (C) 2007, Emmanuele Bassi
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __GTK_RECENT_ACTION_H__
-#define __GTK_RECENT_ACTION_H__
-
-#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
-#error "Only <gtk/gtk.h> can be included directly."
-#endif
-
-#include <gtk/gtkaction.h>
-#include <gtk/gtkrecentmanager.h>
-
-G_BEGIN_DECLS
-
-#define GTK_TYPE_RECENT_ACTION (gtk_recent_action_get_type ())
-#define GTK_RECENT_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RECENT_ACTION, GtkRecentAction))
-#define GTK_IS_RECENT_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RECENT_ACTION))
-#define GTK_RECENT_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_RECENT_ACTION, GtkRecentActionClass))
-#define GTK_IS_RECENT_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RECENT_ACTION))
-#define GTK_RECENT_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RECENT_ACTION, GtkRecentActionClass))
-
-typedef struct _GtkRecentAction GtkRecentAction;
-typedef struct _GtkRecentActionPrivate GtkRecentActionPrivate;
-typedef struct _GtkRecentActionClass GtkRecentActionClass;
-
-struct _GtkRecentAction
-{
- GtkAction parent_instance;
-
- /*< private >*/
- GtkRecentActionPrivate *priv;
-};
-
-struct _GtkRecentActionClass
-{
- GtkActionClass parent_class;
-
- /* Padding for future expansion */
- void (*_gtk_reserved1) (void);
- void (*_gtk_reserved2) (void);
- void (*_gtk_reserved3) (void);
- void (*_gtk_reserved4) (void);
-};
-
-GDK_DEPRECATED_IN_3_10
-GType gtk_recent_action_get_type (void) G_GNUC_CONST;
-GDK_DEPRECATED_IN_3_10
-GtkAction *gtk_recent_action_new (const gchar *name,
- const gchar *label,
- const gchar *tooltip,
- const gchar *stock_id);
-GDK_DEPRECATED_IN_3_10
-GtkAction *gtk_recent_action_new_for_manager (const gchar *name,
- const gchar *label,
- const gchar *tooltip,
- const gchar *stock_id,
- GtkRecentManager *manager);
-GDK_DEPRECATED_IN_3_10
-gboolean gtk_recent_action_get_show_numbers (GtkRecentAction *action);
-GDK_DEPRECATED_IN_3_10
-void gtk_recent_action_set_show_numbers (GtkRecentAction *action,
- gboolean show_numbers);
-
-G_END_DECLS
-
-#endif /* __GTK_RECENT_ACTION_H__ */
#include "gtkrecentchooser.h"
#include "gtkrecentchooserprivate.h"
#include "gtkrecentmanager.h"
-#include "gtkrecentaction.h"
-#include "gtkactivatable.h"
+#include "deprecated/gtkrecentaction.h"
+#include "deprecated/gtkactivatable.h"
#include "gtkintl.h"
#include "gtktypebuiltins.h"
#include "gtkprivate.h"
#endif
#include "gtkicontheme.h"
-#include "gtkiconfactory.h"
+#include "deprecated/gtkiconfactory.h"
#include "gtksettings.h"
#include "gtktreeview.h"
#include "gtkliststore.h"
#include "gtkbox.h"
#include "gtkpaned.h"
#include "gtkimage.h"
-#include "gtkimagemenuitem.h"
+#include "deprecated/gtkimagemenuitem.h"
#include "gtkintl.h"
#include "gtklabel.h"
#include "gtkmenuitem.h"
#include "gtktooltip.h"
#include "gtktypebuiltins.h"
#include "gtkorientable.h"
-#include "gtkactivatable.h"
+#include "deprecated/gtkactivatable.h"
#include "gtkrecentmanager.h"
#include "gtkrecentfilter.h"
#include "gtkrecentchooserprivate.h"
#include "gtkrecentchoosermenu.h"
-#include "gtkstock.h"
+#include "deprecated/gtkstock.h"
#include "gtkicontheme.h"
-#include "gtkiconfactory.h"
+#include "deprecated/gtkiconfactory.h"
#include "gtkintl.h"
#include "gtksettings.h"
#include "gtkmenushell.h"
#include "gtkmenuitem.h"
-#include "gtkimagemenuitem.h"
+#include "deprecated/gtkimagemenuitem.h"
#include "gtkseparatormenuitem.h"
#include "gtkmenu.h"
#include "gtkimage.h"
#include "gtklabel.h"
#include "gtktooltip.h"
-#include "gtkactivatable.h"
+#include "deprecated/gtkactivatable.h"
#include "gtktypebuiltins.h"
#include "gtkprivate.h"
#include "gtkrecentmanager.h"
#include "gtkrecentchooser.h"
-#include "gtkactivatable.h"
+#include "deprecated/gtkactivatable.h"
G_BEGIN_DECLS
#include "gtkrecentmanager.h"
#include "gtkintl.h"
#include "gtksettings.h"
-#include "gtkstock.h"
+#include "deprecated/gtkstock.h"
#include "gtkicontheme.h"
#include "gtktypebuiltins.h"
#include "gtkprivate.h"
#include "gtkbindings.h"
#include "gtkbuildable.h"
#include "gtkbuilderprivate.h"
-#include "gtkiconfactory.h"
+#include "deprecated/gtkiconfactory.h"
#include "gtkicontheme.h"
#include "gtkintl.h"
#include "gtkmarshalers.h"
#include "gtkorientableprivate.h"
#include "gtkprivate.h"
#include "gtksettings.h"
-#include "gtkstock.h"
+#include "deprecated/gtkstock.h"
#include "gtktypebuiltins.h"
#include "gtkwidgetpath.h"
#include "gtkwidgetprivate.h"
#include "gtkstatusicon.h"
#include "gtkintl.h"
-#include "gtkiconfactory.h"
+#include "deprecated/gtkiconfactory.h"
#include "gtkiconhelperprivate.h"
#include "gtkmain.h"
#include "gtkmarshalers.h"
+++ /dev/null
-/* GTK - The GIMP Toolkit
- * Copyright (C) 2000 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#include "config.h"
-
-#define GDK_DISABLE_DEPRECATION_WARNINGS
-
-#include <string.h>
-
-#include "gtkprivate.h"
-#include "gtkstock.h"
-#include "gtkiconfactory.h"
-#include "gtkintl.h"
-
-/**
- * SECTION:gtkstock
- * @Short_description:
-Prebuilt common menu/toolbar items and corresponding icons
- * @Title: Stock Items
- *
- * Stock items represent commonly-used menu or toolbar items such as
- * "Open" or "Exit". Each stock item is identified by a stock ID;
- * stock IDs are just strings, but macros such as #GTK_STOCK_OPEN are
- * provided to avoid typing mistakes in the strings.
- * Applications can register their own stock items in addition to those
- * built-in to GTK+.
- *
- * Each stock ID can be associated with a #GtkStockItem, which contains
- * the user-visible label, keyboard accelerator, and translation domain
- * of the menu or toolbar item; and/or with an icon stored in a
- * #GtkIconFactory. See <link
- * linkend="gtk3-Themeable-Stock-Images">GtkIconFactory</link> for
- * more information on stock icons. The connection between a
- * #GtkStockItem and stock icons is purely conventional (by virtue of
- * using the same stock ID); it's possible to register a stock item but
- * no icon, and vice versa. Stock icons may have a RTL variant which gets
- * used for right-to-left locales.
- */
-
-static GHashTable *translate_hash = NULL;
-static GHashTable *stock_hash = NULL;
-static void init_stock_hash (void);
-
-/* We use an unused modifier bit to mark stock items which
- * must be freed when they are removed from the hash table.
- */
-#define NON_STATIC_MASK (1 << 29)
-
-/* Magic value which is automatically replaced by the primary accel modifier */
-#define PRIMARY_MODIFIER 0xffffffff
-
-typedef struct _GtkStockTranslateFunc GtkStockTranslateFunc;
-struct _GtkStockTranslateFunc
-{
- GtkTranslateFunc func;
- gpointer data;
- GDestroyNotify notify;
-};
-
-static void
-real_add (const GtkStockItem *items,
- guint n_items,
- gboolean copy,
- gboolean replace_primary)
-{
- int i;
-
- init_stock_hash ();
-
- if (n_items == 0)
- return;
-
- i = 0;
- while (i < n_items)
- {
- gpointer old_key, old_value;
- const GtkStockItem *item = &items[i];
-
- if (replace_primary && item->modifier == PRIMARY_MODIFIER)
- {
- item = gtk_stock_item_copy (item);
- ((GtkStockItem *)item)->modifier = (NON_STATIC_MASK |
- _gtk_get_primary_accel_mod ());
- }
- else
- {
- if (item->modifier & NON_STATIC_MASK)
- {
- g_warning ("Bit 29 set in stock accelerator.\n");
- copy = TRUE;
- }
-
- if (copy)
- {
- item = gtk_stock_item_copy (item);
- ((GtkStockItem *)item)->modifier |= NON_STATIC_MASK;
- }
- }
-
- if (g_hash_table_lookup_extended (stock_hash, item->stock_id,
- &old_key, &old_value))
- {
- g_hash_table_remove (stock_hash, old_key);
- if (((GtkStockItem *)old_value)->modifier & NON_STATIC_MASK)
- gtk_stock_item_free (old_value);
- }
-
- g_hash_table_insert (stock_hash,
- (gchar*)item->stock_id, (GtkStockItem*)item);
-
- ++i;
- }
-}
-
-/**
- * gtk_stock_add:
- * @items: (array length=n_items): a #GtkStockItem or array of items
- * @n_items: number of #GtkStockItem in @items
- *
- * Registers each of the stock items in @items. If an item already
- * exists with the same stock ID as one of the @items, the old item
- * gets replaced. The stock items are copied, so GTK+ does not hold
- * any pointer into @items and @items can be freed. Use
- * gtk_stock_add_static() if @items is persistent and GTK+ need not
- * copy the array.
- *
- * Deprecated: 3.10
- **/
-void
-gtk_stock_add (const GtkStockItem *items,
- guint n_items)
-{
- g_return_if_fail (items != NULL);
-
- real_add (items, n_items, TRUE, FALSE);
-}
-
-/**
- * gtk_stock_add_static:
- * @items: (array length=n_items): a #GtkStockItem or array of #GtkStockItem
- * @n_items: number of items
- *
- * Same as gtk_stock_add(), but doesn't copy @items, so
- * @items must persist until application exit.
- *
- * Deprecated: 3.10
- **/
-void
-gtk_stock_add_static (const GtkStockItem *items,
- guint n_items)
-{
- g_return_if_fail (items != NULL);
-
- real_add (items, n_items, FALSE, FALSE);
-}
-
-/**
- * gtk_stock_lookup:
- * @stock_id: a stock item name
- * @item: (out): stock item to initialize with values
- *
- * Fills @item with the registered values for @stock_id, returning %TRUE
- * if @stock_id was known.
- *
- * Return value: %TRUE if @item was initialized
- *
- * Deprecated: 3.10
- **/
-gboolean
-gtk_stock_lookup (const gchar *stock_id,
- GtkStockItem *item)
-{
- const GtkStockItem *found;
-
- g_return_val_if_fail (stock_id != NULL, FALSE);
- g_return_val_if_fail (item != NULL, FALSE);
-
- init_stock_hash ();
-
- found = g_hash_table_lookup (stock_hash, stock_id);
-
- if (found)
- {
- *item = *found;
- item->modifier &= ~NON_STATIC_MASK;
- if (item->label)
- {
- GtkStockTranslateFunc *translate;
-
- if (item->translation_domain)
- translate = (GtkStockTranslateFunc *)
- g_hash_table_lookup (translate_hash, item->translation_domain);
- else
- translate = NULL;
-
- if (translate != NULL && translate->func != NULL)
- item->label = (* translate->func) (item->label, translate->data);
- else
- item->label = (gchar *) g_dgettext (item->translation_domain, item->label);
- }
- }
-
- return found != NULL;
-}
-
-/**
- * gtk_stock_list_ids:
- *
- * Retrieves a list of all known stock IDs added to a #GtkIconFactory
- * or registered with gtk_stock_add(). The list must be freed with g_slist_free(),
- * and each string in the list must be freed with g_free().
- *
- * Return value: (element-type utf8) (transfer full): a list of known stock IDs
- *
- * Deprecated: 3.10
- **/
-GSList*
-gtk_stock_list_ids (void)
-{
- GList *ids;
- GList *icon_ids;
- GSList *retval;
- const gchar *last_id;
-
- init_stock_hash ();
-
- ids = g_hash_table_get_keys (stock_hash);
- icon_ids = _gtk_icon_factory_list_ids ();
- ids = g_list_concat (ids, icon_ids);
-
- ids = g_list_sort (ids, (GCompareFunc)strcmp);
-
- last_id = NULL;
- retval = NULL;
- while (ids != NULL)
- {
- GList *next;
-
- next = g_list_next (ids);
-
- if (last_id && strcmp (ids->data, last_id) == 0)
- {
- /* duplicate, ignore */
- }
- else
- {
- retval = g_slist_prepend (retval, g_strdup (ids->data));
- last_id = ids->data;
- }
-
- g_list_free_1 (ids);
-
- ids = next;
- }
-
- return retval;
-}
-
-/**
- * gtk_stock_item_copy: (skip)
- * @item: a #GtkStockItem
- *
- * Copies a stock item, mostly useful for language bindings and not in applications.
- *
- * Return value: a new #GtkStockItem
- *
- * Deprecated: 3.10
- **/
-GtkStockItem *
-gtk_stock_item_copy (const GtkStockItem *item)
-{
- GtkStockItem *copy;
-
- g_return_val_if_fail (item != NULL, NULL);
-
- copy = g_new (GtkStockItem, 1);
-
- *copy = *item;
-
- copy->stock_id = g_strdup (item->stock_id);
- copy->label = g_strdup (item->label);
- copy->translation_domain = g_strdup (item->translation_domain);
-
- return copy;
-}
-
-/**
- * gtk_stock_item_free:
- * @item: a #GtkStockItem
- *
- * Frees a stock item allocated on the heap, such as one returned by
- * gtk_stock_item_copy(). Also frees the fields inside the stock item,
- * if they are not %NULL.
- *
- * Deprecated: 3.10
- **/
-void
-gtk_stock_item_free (GtkStockItem *item)
-{
- g_return_if_fail (item != NULL);
-
- g_free ((gchar*)item->stock_id);
- g_free ((gchar*)item->label);
- g_free ((gchar*)item->translation_domain);
-
- g_free (item);
-}
-
-static const GtkStockItem builtin_items [] =
-{
- /* KEEP IN SYNC with gtkiconfactory.c stock icons, when appropriate */
-
- { GTK_STOCK_DIALOG_INFO, NC_("Stock label", "Information"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_DIALOG_WARNING, NC_("Stock label", "Warning"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_DIALOG_ERROR, NC_("Stock label", "Error"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_DIALOG_QUESTION, NC_("Stock label", "Question"), 0, 0, GETTEXT_PACKAGE },
-
- /* FIXME these need accelerators when appropriate, and
- * need the mnemonics to be rationalized
- */
- { GTK_STOCK_ABOUT, NC_("Stock label", "_About"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_ADD, NC_("Stock label", "_Add"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_APPLY, NC_("Stock label", "_Apply"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_BOLD, NC_("Stock label", "_Bold"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_CANCEL, NC_("Stock label", "_Cancel"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_CDROM, NC_("Stock label", "_CD-ROM"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_CLEAR, NC_("Stock label", "_Clear"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_CLOSE, NC_("Stock label", "_Close"), PRIMARY_MODIFIER, 'w', GETTEXT_PACKAGE },
- { GTK_STOCK_CONNECT, NC_("Stock label", "C_onnect"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_CONVERT, NC_("Stock label", "_Convert"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_COPY, NC_("Stock label", "_Copy"), PRIMARY_MODIFIER, 'c', GETTEXT_PACKAGE },
- { GTK_STOCK_CUT, NC_("Stock label", "Cu_t"), PRIMARY_MODIFIER, 'x', GETTEXT_PACKAGE },
- { GTK_STOCK_DELETE, NC_("Stock label", "_Delete"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_DISCARD, NC_("Stock label", "_Discard"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_DISCONNECT, NC_("Stock label", "_Disconnect"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_EXECUTE, NC_("Stock label", "_Execute"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_EDIT, NC_("Stock label", "_Edit"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_FILE, NC_("Stock label", "_File"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_FIND, NC_("Stock label", "_Find"), PRIMARY_MODIFIER, 'f', GETTEXT_PACKAGE },
- { GTK_STOCK_FIND_AND_REPLACE, NC_("Stock label", "Find and _Replace"), PRIMARY_MODIFIER, 'r', GETTEXT_PACKAGE },
- { GTK_STOCK_FLOPPY, NC_("Stock label", "_Floppy"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_FULLSCREEN, NC_("Stock label", "_Fullscreen"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_LEAVE_FULLSCREEN, NC_("Stock label", "_Leave Fullscreen"), 0, 0, GETTEXT_PACKAGE },
- /* This is a navigation label as in "go to the bottom of the page" */
- { GTK_STOCK_GOTO_BOTTOM, NC_("Stock label, navigation", "_Bottom"), 0, 0, GETTEXT_PACKAGE "-navigation" },
- /* This is a navigation label as in "go to the first page" */
- { GTK_STOCK_GOTO_FIRST, NC_("Stock label, navigation", "_First"), 0, 0, GETTEXT_PACKAGE "-navigation" },
- /* This is a navigation label as in "go to the last page" */
- { GTK_STOCK_GOTO_LAST, NC_("Stock label, navigation", "_Last"), 0, 0, GETTEXT_PACKAGE "-navigation" },
- /* This is a navigation label as in "go to the top of the page" */
- { GTK_STOCK_GOTO_TOP, NC_("Stock label, navigation", "_Top"), 0, 0, GETTEXT_PACKAGE "-navigation" },
- /* This is a navigation label as in "go back" */
- { GTK_STOCK_GO_BACK, NC_("Stock label, navigation", "_Back"), 0, 0, GETTEXT_PACKAGE "-navigation" },
- /* This is a navigation label as in "go down" */
- { GTK_STOCK_GO_DOWN, NC_("Stock label, navigation", "_Down"), 0, 0, GETTEXT_PACKAGE "-navigation" },
- /* This is a navigation label as in "go forward" */
- { GTK_STOCK_GO_FORWARD, NC_("Stock label, navigation", "_Forward"), 0, 0, GETTEXT_PACKAGE "-navigation" },
- /* This is a navigation label as in "go up" */
- { GTK_STOCK_GO_UP, NC_("Stock label, navigation", "_Up"), 0, 0, GETTEXT_PACKAGE "-navigation" },
- { GTK_STOCK_HARDDISK, NC_("Stock label", "_Hard Disk"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_HELP, NC_("Stock label", "_Help"), 0, GDK_KEY_F1, GETTEXT_PACKAGE },
- { GTK_STOCK_HOME, NC_("Stock label", "_Home"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_INDENT, NC_("Stock label", "Increase Indent"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_UNINDENT, NC_("Stock label", "Decrease Indent"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_INDEX, NC_("Stock label", "_Index"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_INFO, NC_("Stock label", "_Information"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_ITALIC, NC_("Stock label", "_Italic"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_JUMP_TO, NC_("Stock label", "_Jump to"), 0, 0, GETTEXT_PACKAGE },
- /* This is about text justification, "centered text" */
- { GTK_STOCK_JUSTIFY_CENTER, NC_("Stock label", "_Center"), 0, 0, GETTEXT_PACKAGE },
- /* This is about text justification */
- { GTK_STOCK_JUSTIFY_FILL, NC_("Stock label", "_Fill"), 0, 0, GETTEXT_PACKAGE },
- /* This is about text justification, "left-justified text" */
- { GTK_STOCK_JUSTIFY_LEFT, NC_("Stock label", "_Left"), 0, 0, GETTEXT_PACKAGE },
- /* This is about text justification, "right-justified text" */
- { GTK_STOCK_JUSTIFY_RIGHT, NC_("Stock label", "_Right"), 0, 0, GETTEXT_PACKAGE },
-
- /* Media label, as in "fast forward" */
- { GTK_STOCK_MEDIA_FORWARD, NC_("Stock label, media", "_Forward"), 0, 0, GETTEXT_PACKAGE "-media" },
- /* Media label, as in "next song" */
- { GTK_STOCK_MEDIA_NEXT, NC_("Stock label, media", "_Next"), 0, 0, GETTEXT_PACKAGE "-media" },
- /* Media label, as in "pause music" */
- { GTK_STOCK_MEDIA_PAUSE, NC_("Stock label, media", "P_ause"), 0, 0, GETTEXT_PACKAGE "-media" },
- /* Media label, as in "play music" */
- { GTK_STOCK_MEDIA_PLAY, NC_("Stock label, media", "_Play"), 0, 0, GETTEXT_PACKAGE "-media" },
- /* Media label, as in "previous song" */
- { GTK_STOCK_MEDIA_PREVIOUS, NC_("Stock label, media", "Pre_vious"), 0, 0, GETTEXT_PACKAGE "-media" },
- /* Media label */
- { GTK_STOCK_MEDIA_RECORD, NC_("Stock label, media", "_Record"), 0, 0, GETTEXT_PACKAGE "-media" },
- /* Media label */
- { GTK_STOCK_MEDIA_REWIND, NC_("Stock label, media", "R_ewind"), 0, 0, GETTEXT_PACKAGE "-media" },
- /* Media label */
- { GTK_STOCK_MEDIA_STOP, NC_("Stock label, media", "_Stop"), 0, 0, GETTEXT_PACKAGE "-media" },
- { GTK_STOCK_NETWORK, NC_("Stock label", "_Network"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_NEW, NC_("Stock label", "_New"), PRIMARY_MODIFIER, 'n', GETTEXT_PACKAGE },
- { GTK_STOCK_NO, NC_("Stock label", "_No"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_OK, NC_("Stock label", "_OK"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_OPEN, NC_("Stock label", "_Open"), PRIMARY_MODIFIER, 'o', GETTEXT_PACKAGE },
- /* Page orientation */
- { GTK_STOCK_ORIENTATION_LANDSCAPE, NC_("Stock label", "Landscape"), 0, 0, GETTEXT_PACKAGE },
- /* Page orientation */
- { GTK_STOCK_ORIENTATION_PORTRAIT, NC_("Stock label", "Portrait"), 0, 0, GETTEXT_PACKAGE },
- /* Page orientation */
- { GTK_STOCK_ORIENTATION_REVERSE_LANDSCAPE, NC_("Stock label", "Reverse landscape"), 0, 0, GETTEXT_PACKAGE },
- /* Page orientation */
- { GTK_STOCK_ORIENTATION_REVERSE_PORTRAIT, NC_("Stock label", "Reverse portrait"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_PAGE_SETUP, NC_("Stock label", "Page Set_up"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_PASTE, NC_("Stock label", "_Paste"), PRIMARY_MODIFIER, 'v', GETTEXT_PACKAGE },
- { GTK_STOCK_PREFERENCES, NC_("Stock label", "_Preferences"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_PRINT, NC_("Stock label", "_Print"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_PRINT_PREVIEW, NC_("Stock label", "Print Pre_view"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_PROPERTIES, NC_("Stock label", "_Properties"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_QUIT, NC_("Stock label", "_Quit"), PRIMARY_MODIFIER, 'q', GETTEXT_PACKAGE },
- { GTK_STOCK_REDO, NC_("Stock label", "_Redo"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_REFRESH, NC_("Stock label", "_Refresh"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_REMOVE, NC_("Stock label", "_Remove"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_REVERT_TO_SAVED, NC_("Stock label", "_Revert"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_SAVE, NC_("Stock label", "_Save"), PRIMARY_MODIFIER, 's', GETTEXT_PACKAGE },
- { GTK_STOCK_SAVE_AS, NC_("Stock label", "Save _As"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_SELECT_ALL, NC_("Stock label", "Select _All"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_SELECT_COLOR, NC_("Stock label", "_Color"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_SELECT_FONT, NC_("Stock label", "_Font"), 0, 0, GETTEXT_PACKAGE },
- /* Sorting direction */
- { GTK_STOCK_SORT_ASCENDING, NC_("Stock label", "_Ascending"), 0, 0, GETTEXT_PACKAGE },
- /* Sorting direction */
- { GTK_STOCK_SORT_DESCENDING, NC_("Stock label", "_Descending"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_SPELL_CHECK, NC_("Stock label", "_Spell Check"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_STOP, NC_("Stock label", "_Stop"), 0, 0, GETTEXT_PACKAGE },
- /* Font variant */
- { GTK_STOCK_STRIKETHROUGH, NC_("Stock label", "_Strikethrough"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_UNDELETE, NC_("Stock label", "_Undelete"), 0, 0, GETTEXT_PACKAGE },
- /* Font variant */
- { GTK_STOCK_UNDERLINE, NC_("Stock label", "_Underline"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_UNDO, NC_("Stock label", "_Undo"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_YES, NC_("Stock label", "_Yes"), 0, 0, GETTEXT_PACKAGE },
- /* Zoom */
- { GTK_STOCK_ZOOM_100, NC_("Stock label", "_Normal Size"), 0, 0, GETTEXT_PACKAGE },
- /* Zoom */
- { GTK_STOCK_ZOOM_FIT, NC_("Stock label", "Best _Fit"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_ZOOM_IN, NC_("Stock label", "Zoom _In"), 0, 0, GETTEXT_PACKAGE },
- { GTK_STOCK_ZOOM_OUT, NC_("Stock label", "Zoom _Out"), 0, 0, GETTEXT_PACKAGE }
-};
-
-/**
- * gtk_stock_set_translate_func:
- * @domain: the translation domain for which @func shall be used
- * @func: a #GtkTranslateFunc
- * @data: data to pass to @func
- * @notify: a #GDestroyNotify that is called when @data is
- * no longer needed
- *
- * Sets a function to be used for translating the @label of
- * a stock item.
- *
- * If no function is registered for a translation domain,
- * g_dgettext() is used.
- *
- * The function is used for all stock items whose
- * @translation_domain matches @domain. Note that it is possible
- * to use strings different from the actual gettext translation domain
- * of your application for this, as long as your #GtkTranslateFunc uses
- * the correct domain when calling dgettext(). This can be useful, e.g.
- * when dealing with message contexts:
- *
- * |[
- * GtkStockItem items[] = {
- * { MY_ITEM1, NC_("odd items", "Item 1"), 0, 0, "odd-item-domain" },
- * { MY_ITEM2, NC_("even items", "Item 2"), 0, 0, "even-item-domain" },
- * };
- *
- * gchar *
- * my_translate_func (const gchar *msgid,
- * gpointer data)
- * {
- * gchar *msgctxt = data;
- *
- * return (gchar*)g_dpgettext2 (GETTEXT_PACKAGE, msgctxt, msgid);
- * }
- *
- * /* ... */
- *
- * gtk_stock_add (items, G_N_ELEMENTS (items));
- * gtk_stock_set_translate_func ("odd-item-domain", my_translate_func, "odd items");
- * gtk_stock_set_translate_func ("even-item-domain", my_translate_func, "even items");
- * ]|
- *
- * Since: 2.8
- *
- * Deprecated: 3.10
- */
-void
-gtk_stock_set_translate_func (const gchar *domain,
- GtkTranslateFunc func,
- gpointer data,
- GDestroyNotify notify)
-{
- GtkStockTranslateFunc *translate;
- gchar *domainname;
-
- domainname = g_strdup (domain);
-
- translate = (GtkStockTranslateFunc *)
- g_hash_table_lookup (translate_hash, domainname);
-
- if (translate)
- {
- if (translate->notify)
- (* translate->notify) (translate->data);
- }
- else
- translate = g_new0 (GtkStockTranslateFunc, 1);
-
- translate->func = func;
- translate->data = data;
- translate->notify = notify;
-
- g_hash_table_insert (translate_hash, domainname, translate);
-}
-
-static gchar *
-sgettext_swapped (const gchar *msgid,
- gpointer data)
-{
- gchar *msgctxt = data;
-
- return (gchar *)g_dpgettext2 (GETTEXT_PACKAGE, msgctxt, msgid);
-}
-
-static void
-init_stock_hash (void)
-{
- if (stock_hash == NULL)
- {
- stock_hash = g_hash_table_new (g_str_hash, g_str_equal);
-
- real_add (builtin_items, G_N_ELEMENTS (builtin_items), FALSE, TRUE);
- }
-
- if (translate_hash == NULL)
- {
- translate_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, NULL);
-
- gtk_stock_set_translate_func (GETTEXT_PACKAGE,
- sgettext_swapped,
- "Stock label",
- NULL);
- gtk_stock_set_translate_func (GETTEXT_PACKAGE "-navigation",
- sgettext_swapped,
- "Stock label, navigation",
- NULL);
- gtk_stock_set_translate_func (GETTEXT_PACKAGE "-media",
- sgettext_swapped,
- "Stock label, media",
- NULL);
- }
-}
+++ /dev/null
-/* GTK - The GIMP Toolkit
- * Copyright (C) 2000 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#ifndef __GTK_STOCK_H__
-#define __GTK_STOCK_H__
-
-
-#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
-#error "Only <gtk/gtk.h> can be included directly."
-#endif
-
-#include <gdk/gdk.h>
-
-G_BEGIN_DECLS
-
-/*
- * GtkTranslateFunc:
- * @path: The id of the message. In #GtkActionGroup this will be a label
- * or tooltip from a #GtkActionEntry.
- * @func_data: user data passed in when registering the function
- *
- * The function used to translate messages in e.g. #GtkIconFactory
- * and #GtkActionGroup.
- *
- * Returns: the translated message
- *
- * Deprecated: 3.10
- */
-typedef gchar * (*GtkTranslateFunc) (const gchar *path,
- gpointer func_data);
-
-typedef struct _GtkStockItem GtkStockItem;
-
-struct _GtkStockItem
-{
- gchar *stock_id;
- gchar *label;
- GdkModifierType modifier;
- guint keyval;
- gchar *translation_domain;
-};
-
-GDK_DEPRECATED_IN_3_10
-void gtk_stock_add (const GtkStockItem *items,
- guint n_items);
-GDK_DEPRECATED_IN_3_10
-void gtk_stock_add_static (const GtkStockItem *items,
- guint n_items);
-GDK_DEPRECATED_IN_3_10
-gboolean gtk_stock_lookup (const gchar *stock_id,
- GtkStockItem *item);
-
-/* Should free the list (and free each string in it also).
- * This function is only useful for GUI builders and such.
- */
-GDK_DEPRECATED_IN_3_10
-GSList* gtk_stock_list_ids (void);
-
-GDK_DEPRECATED_IN_3_10
-GtkStockItem *gtk_stock_item_copy (const GtkStockItem *item);
-GDK_DEPRECATED_IN_3_10
-void gtk_stock_item_free (GtkStockItem *item);
-
-GDK_DEPRECATED_IN_3_10
-void gtk_stock_set_translate_func (const gchar *domain,
- GtkTranslateFunc func,
- gpointer data,
- GDestroyNotify notify);
-
-/* the following type exists just so we can get deprecation warnings */
-#ifndef GDK_DISABLE_DEPRECATION_WARNINGS
-#if GDK_VERSION_MIN_REQUIRED >= GDK_VERSION_3_10
-G_DEPRECATED
-#endif
-#endif
-typedef char * GtkStock;
-
-/* Stock IDs (not all are stock items; some are images only) */
-/**
- * GTK_STOCK_ABOUT:
- *
- * The "About" item.
- * <inlinegraphic fileref="help-about.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.6
- *
- * Deprecated: 3.10: Use named icon "help-about" or the label "_About".
- */
-#define GTK_STOCK_ABOUT ((GtkStock)"gtk-about")
-
-/**
- * GTK_STOCK_ADD:
- *
- * The "Add" item.
- * <inlinegraphic fileref="list-add.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "list-add" or the label "_Add".
- */
-#define GTK_STOCK_ADD ((GtkStock)"gtk-add")
-
-/**
- * GTK_STOCK_APPLY:
- *
- * The "Apply" item.
- * <inlinegraphic fileref="gtk-apply.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Do not use an icon. Use label "_Apply".
- */
-#define GTK_STOCK_APPLY ((GtkStock)"gtk-apply")
-
-/**
- * GTK_STOCK_BOLD:
- *
- * The "Bold" item.
- * <inlinegraphic fileref="format-text-bold.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "format-text-bold".
- */
-#define GTK_STOCK_BOLD ((GtkStock)"gtk-bold")
-
-/**
- * GTK_STOCK_CANCEL:
- *
- * The "Cancel" item.
- * <inlinegraphic fileref="gtk-cancel.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Do not use an icon. Use label "_Cancel".
- */
-#define GTK_STOCK_CANCEL ((GtkStock)"gtk-cancel")
-
-/**
- * GTK_STOCK_CAPS_LOCK_WARNING:
- *
- * The "Caps Lock Warning" icon.
- * <inlinegraphic fileref="gtk-caps-lock-warning.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.16
- *
- * Deprecated: 3.10: Use named icon "dialog-warning-symbolic".
- */
-#define GTK_STOCK_CAPS_LOCK_WARNING ((GtkStock)"gtk-caps-lock-warning")
-
-/**
- * GTK_STOCK_CDROM:
- *
- * The "CD-Rom" item.
- * <inlinegraphic fileref="media-optical.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "media-optical".
- */
-#define GTK_STOCK_CDROM ((GtkStock)"gtk-cdrom")
-
-/**
- * GTK_STOCK_CLEAR:
- *
- * The "Clear" item.
- * <inlinegraphic fileref="edit-clear.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "edit-clear".
- */
-#define GTK_STOCK_CLEAR ((GtkStock)"gtk-clear")
-
-/**
- * GTK_STOCK_CLOSE:
- *
- * The "Close" item.
- * <inlinegraphic fileref="window-close.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "window-close" or the label "_Close".
- */
-#define GTK_STOCK_CLOSE ((GtkStock)"gtk-close")
-
-/**
- * GTK_STOCK_COLOR_PICKER:
- *
- * The "Color Picker" item.
- * <inlinegraphic fileref="gtk-color-picker.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.2
- *
- * Deprecated: 3.10
- */
-#define GTK_STOCK_COLOR_PICKER ((GtkStock)"gtk-color-picker")
-
-/**
- * GTK_STOCK_CONNECT:
- *
- * The "Connect" icon.
- * <inlinegraphic fileref="gtk-connect.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.6
- *
- * Deprecated: 3.10
- */
-#define GTK_STOCK_CONNECT ((GtkStock)"gtk-connect")
-
-/**
- * GTK_STOCK_CONVERT:
- *
- * The "Convert" item.
- * <inlinegraphic fileref="gtk-convert.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10
- */
-#define GTK_STOCK_CONVERT ((GtkStock)"gtk-convert")
-
-/**
- * GTK_STOCK_COPY:
- *
- * The "Copy" item.
- * <inlinegraphic fileref="edit-copy.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Do not use an icon. Use label "_Copy".
- */
-#define GTK_STOCK_COPY ((GtkStock)"gtk-copy")
-
-/**
- * GTK_STOCK_CUT:
- *
- * The "Cut" item.
- * <inlinegraphic fileref="edit-cut.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Do not use an icon. Use label "Cu_t".
- */
-#define GTK_STOCK_CUT ((GtkStock)"gtk-cut")
-
-/**
- * GTK_STOCK_DELETE:
- *
- * The "Delete" item.
- * <inlinegraphic fileref="edit-delete.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Do not use an icon. Use label "_Delete".
- */
-#define GTK_STOCK_DELETE ((GtkStock)"gtk-delete")
-
-/**
- * GTK_STOCK_DIALOG_AUTHENTICATION:
- *
- * The "Authentication" item.
- * <inlinegraphic fileref="dialog-password.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.4
- *
- * Deprecated: 3.10: Use named icon "dialog-password".
- */
-#define GTK_STOCK_DIALOG_AUTHENTICATION ((GtkStock)"gtk-dialog-authentication")
-
-/**
- * GTK_STOCK_DIALOG_INFO:
- *
- * The "Information" item.
- * <inlinegraphic fileref="dialog-information.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "dialog-information".
- */
-#define GTK_STOCK_DIALOG_INFO ((GtkStock)"gtk-dialog-info")
-
-/**
- * GTK_STOCK_DIALOG_WARNING:
- *
- * The "Warning" item.
- * <inlinegraphic fileref="dialog-warning.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "dialog-warning".
- */
-#define GTK_STOCK_DIALOG_WARNING ((GtkStock)"gtk-dialog-warning")
-
-/**
- * GTK_STOCK_DIALOG_ERROR:
- *
- * The "Error" item.
- * <inlinegraphic fileref="dialog-error.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "dialog-error".
- */
-#define GTK_STOCK_DIALOG_ERROR ((GtkStock)"gtk-dialog-error")
-
-/**
- * GTK_STOCK_DIALOG_QUESTION:
- *
- * The "Question" item.
- * <inlinegraphic fileref="dialog-question.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "dialog-question".
- */
-#define GTK_STOCK_DIALOG_QUESTION ((GtkStock)"gtk-dialog-question")
-
-/**
- * GTK_STOCK_DIRECTORY:
- *
- * The "Directory" icon.
- * <inlinegraphic fileref="folder.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.6
- *
- * Deprecated: 3.10: Use named icon "folder".
- */
-#define GTK_STOCK_DIRECTORY ((GtkStock)"gtk-directory")
-
-/**
- * GTK_STOCK_DISCARD:
- *
- * The "Discard" item.
- *
- * Since: 2.12
- *
- * Deprecated: 3.10
- */
-#define GTK_STOCK_DISCARD ((GtkStock)"gtk-discard")
-
-/**
- * GTK_STOCK_DISCONNECT:
- *
- * The "Disconnect" icon.
- * <inlinegraphic fileref="gtk-disconnect.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.6
- *
- * Deprecated: 3.10
- */
-#define GTK_STOCK_DISCONNECT ((GtkStock)"gtk-disconnect")
-
-/**
- * GTK_STOCK_DND:
- *
- * The "Drag-And-Drop" icon.
- * <inlinegraphic fileref="gtk-dnd.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10
- */
-#define GTK_STOCK_DND ((GtkStock)"gtk-dnd")
-
-/**
- * GTK_STOCK_DND_MULTIPLE:
- *
- * The "Drag-And-Drop multiple" icon.
- * <inlinegraphic fileref="gtk-dnd-multiple.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10
- */
-#define GTK_STOCK_DND_MULTIPLE ((GtkStock)"gtk-dnd-multiple")
-
-/**
- * GTK_STOCK_EDIT:
- *
- * The "Edit" item.
- * <inlinegraphic fileref="gtk-edit.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.6
- *
- * Deprecated: 3.10
- */
-#define GTK_STOCK_EDIT ((GtkStock)"gtk-edit")
-
-/**
- * GTK_STOCK_EXECUTE:
- *
- * The "Execute" item.
- * <inlinegraphic fileref="system-run.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "system-run".
- */
-#define GTK_STOCK_EXECUTE ((GtkStock)"gtk-execute")
-
-/**
- * GTK_STOCK_FILE:
- *
- * The "File" item.
- * <inlinegraphic fileref="text-x-generic.png" format="PNG"></inlinegraphic>
- *
- * Since 3.0, this item has a label, before it only had an icon.
- *
- * Since: 2.6
- *
- * Deprecated: 3.10: Use named icon "text-x-generic".
- */
-#define GTK_STOCK_FILE ((GtkStock)"gtk-file")
-
-/**
- * GTK_STOCK_FIND:
- *
- * The "Find" item.
- * <inlinegraphic fileref="edit-find.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "edit-find".
- */
-#define GTK_STOCK_FIND ((GtkStock)"gtk-find")
-
-/**
- * GTK_STOCK_FIND_AND_REPLACE:
- *
- * The "Find and Replace" item.
- * <inlinegraphic fileref="edit-find-replace.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "edit-find-replace".
- */
-#define GTK_STOCK_FIND_AND_REPLACE ((GtkStock)"gtk-find-and-replace")
-
-/**
- * GTK_STOCK_FLOPPY:
- *
- * The "Floppy" item.
- * <inlinegraphic fileref="media-floppy.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10
- */
-#define GTK_STOCK_FLOPPY ((GtkStock)"gtk-floppy")
-
-/**
- * GTK_STOCK_FULLSCREEN:
- *
- * The "Fullscreen" item.
- * <inlinegraphic fileref="view-fullscreen.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.8
- *
- * Deprecated: 3.10: Use named icon "view-fullscreen".
- */
-#define GTK_STOCK_FULLSCREEN ((GtkStock)"gtk-fullscreen")
-
-/**
- * GTK_STOCK_GOTO_BOTTOM:
- *
- * The "Bottom" item.
- * <inlinegraphic fileref="go-bottom.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "go-bottom".
- */
-#define GTK_STOCK_GOTO_BOTTOM ((GtkStock)"gtk-goto-bottom")
-
-/**
- * GTK_STOCK_GOTO_FIRST:
- *
- * The "First" item.
- * <inlinegraphic fileref="go-first-ltr.png" format="PNG"></inlinegraphic>
- * RTL variant
- * <inlinegraphic fileref="go-first-rtl.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "go-first".
- */
-#define GTK_STOCK_GOTO_FIRST ((GtkStock)"gtk-goto-first")
-
-/**
- * GTK_STOCK_GOTO_LAST:
- *
- * The "Last" item.
- * <inlinegraphic fileref="go-last-ltr.png" format="PNG"></inlinegraphic>
- * RTL variant
- * <inlinegraphic fileref="go-last-rtl.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "go-last".
- */
-#define GTK_STOCK_GOTO_LAST ((GtkStock)"gtk-goto-last")
-
-/**
- * GTK_STOCK_GOTO_TOP:
- *
- * The "Top" item.
- * <inlinegraphic fileref="go-top.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "go-top".
- */
-#define GTK_STOCK_GOTO_TOP ((GtkStock)"gtk-goto-top")
-
-/**
- * GTK_STOCK_GO_BACK:
- *
- * The "Back" item.
- * <inlinegraphic fileref="go-previous-ltr.png" format="PNG"></inlinegraphic>
- * RTL variant
- * <inlinegraphic fileref="go-previous-rtl.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "go-previous".
-*/
-#define GTK_STOCK_GO_BACK ((GtkStock)"gtk-go-back")
-
-/**
- * GTK_STOCK_GO_DOWN:
- *
- * The "Down" item.
- * <inlinegraphic fileref="go-down.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "go-down".
- */
-#define GTK_STOCK_GO_DOWN ((GtkStock)"gtk-go-down")
-
-/**
- * GTK_STOCK_GO_FORWARD:
- *
- * The "Forward" item.
- * <inlinegraphic fileref="go-next-ltr.png" format="PNG"></inlinegraphic>
- * RTL variant
- * <inlinegraphic fileref="go-next-rtl.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "go-next".
- */
-#define GTK_STOCK_GO_FORWARD ((GtkStock)"gtk-go-forward")
-
-/**
- * GTK_STOCK_GO_UP:
- *
- * The "Up" item.
- * <inlinegraphic fileref="go-up.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "go-up".
- */
-#define GTK_STOCK_GO_UP ((GtkStock)"gtk-go-up")
-
-/**
- * GTK_STOCK_HARDDISK:
- *
- * The "Harddisk" item.
- * <inlinegraphic fileref="drive-harddisk.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.4
- *
- * Deprecated: 3.10: Use named icon "drive-harddisk".
- */
-#define GTK_STOCK_HARDDISK ((GtkStock)"gtk-harddisk")
-
-/**
- * GTK_STOCK_HELP:
- *
- * The "Help" item.
- * <inlinegraphic fileref="help-contents.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "help-browser".
- */
-#define GTK_STOCK_HELP ((GtkStock)"gtk-help")
-
-/**
- * GTK_STOCK_HOME:
- *
- * The "Home" item.
- * <inlinegraphic fileref="go-home.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "go-home".
- */
-#define GTK_STOCK_HOME ((GtkStock)"gtk-home")
-
-/**
- * GTK_STOCK_INDEX:
- *
- * The "Index" item.
- * <inlinegraphic fileref="gtk-index.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10
- */
-#define GTK_STOCK_INDEX ((GtkStock)"gtk-index")
-
-/**
- * GTK_STOCK_INDENT:
- *
- * The "Indent" item.
- * <inlinegraphic fileref="format-indent-more-ltr.png" format="PNG"></inlinegraphic>
- * RTL variant
- * <inlinegraphic fileref="format-indent-more-rtl.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.4
- *
- * Deprecated: 3.10: Use named icon "format-indent-more".
- */
-#define GTK_STOCK_INDENT ((GtkStock)"gtk-indent")
-
-/**
- * GTK_STOCK_INFO:
- *
- * The "Info" item.
- * <inlinegraphic fileref="dialog-information.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.8
- *
- * Deprecated: 3.10: Use named icon "dialog-information".
- */
-#define GTK_STOCK_INFO ((GtkStock)"gtk-info")
-
-/**
- * GTK_STOCK_ITALIC:
- *
- * The "Italic" item.
- * <inlinegraphic fileref="format-text-italic.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "format-text-italic".
- */
-#define GTK_STOCK_ITALIC ((GtkStock)"gtk-italic")
-
-/**
- * GTK_STOCK_JUMP_TO:
- *
- * The "Jump to" item.
- * <inlinegraphic fileref="go-jump-ltr.png" format="PNG"></inlinegraphic>
- * RTL-variant
- * <inlinegraphic fileref="go-jump-rtl.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "go-jump".
- */
-#define GTK_STOCK_JUMP_TO ((GtkStock)"gtk-jump-to")
-
-/**
- * GTK_STOCK_JUSTIFY_CENTER:
- *
- * The "Center" item.
- * <inlinegraphic fileref="format-justify-center.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "format-justify-center".
- */
-#define GTK_STOCK_JUSTIFY_CENTER ((GtkStock)"gtk-justify-center")
-
-/**
- * GTK_STOCK_JUSTIFY_FILL:
- *
- * The "Fill" item.
- * <inlinegraphic fileref="format-justify-fill.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "format-justify-fill".
- */
-#define GTK_STOCK_JUSTIFY_FILL ((GtkStock)"gtk-justify-fill")
-
-/**
- * GTK_STOCK_JUSTIFY_LEFT:
- *
- * The "Left" item.
- * <inlinegraphic fileref="format-justify-left.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "format-justify-left".
- */
-#define GTK_STOCK_JUSTIFY_LEFT ((GtkStock)"gtk-justify-left")
-
-/**
- * GTK_STOCK_JUSTIFY_RIGHT:
- *
- * The "Right" item.
- * <inlinegraphic fileref="format-justify-right.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "format-justify-right".
- */
-#define GTK_STOCK_JUSTIFY_RIGHT ((GtkStock)"gtk-justify-right")
-
-/**
- * GTK_STOCK_LEAVE_FULLSCREEN:
- *
- * The "Leave Fullscreen" item.
- * <inlinegraphic fileref="view-restore.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.8
- *
- * Deprecated: 3.10: Use named icon "view-restore".
- */
-#define GTK_STOCK_LEAVE_FULLSCREEN ((GtkStock)"gtk-leave-fullscreen")
-
-/**
- * GTK_STOCK_MISSING_IMAGE:
- *
- * The "Missing image" icon.
- * <inlinegraphic fileref="image-missing.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "image-missing".
- */
-#define GTK_STOCK_MISSING_IMAGE ((GtkStock)"gtk-missing-image")
-
-/**
- * GTK_STOCK_MEDIA_FORWARD:
- *
- * The "Media Forward" item.
- * <inlinegraphic fileref="media-seek-forward-ltr.png" format="PNG"></inlinegraphic>
- * RTL variant
- * <inlinegraphic fileref="media-seek-forward-rtl.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.6
- *
- * Deprecated: 3.10: Use named icon "media-seek-forward" or the label "_Forward".
- */
-#define GTK_STOCK_MEDIA_FORWARD ((GtkStock)"gtk-media-forward")
-
-/**
- * GTK_STOCK_MEDIA_NEXT:
- *
- * The "Media Next" item.
- * <inlinegraphic fileref="media-skip-forward-ltr.png" format="PNG"></inlinegraphic>
- * RTL variant
- * <inlinegraphic fileref="media-skip-forward-rtl.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.6
- *
- * Deprecated: 3.10: Use named icon "media-skip-forward" or the label "_Next".
- */
-#define GTK_STOCK_MEDIA_NEXT ((GtkStock)"gtk-media-next")
-
-/**
- * GTK_STOCK_MEDIA_PAUSE:
- *
- * The "Media Pause" item.
- * <inlinegraphic fileref="media-playback-pause.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.6
- *
- * Deprecated: 3.10: Use named icon "media-playback-pause" or the label "P_ause".
- */
-#define GTK_STOCK_MEDIA_PAUSE ((GtkStock)"gtk-media-pause")
-
-/**
- * GTK_STOCK_MEDIA_PLAY:
- *
- * The "Media Play" item.
- * <inlinegraphic fileref="media-playback-start-ltr.png" format="PNG"></inlinegraphic>
- * RTL variant
- * <inlinegraphic fileref="media-playback-start-rtl.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.6
- *
- * Deprecated: 3.10: Use named icon "media-playback-start" or the label "_Play".
- */
-#define GTK_STOCK_MEDIA_PLAY ((GtkStock)"gtk-media-play")
-
-/**
- * GTK_STOCK_MEDIA_PREVIOUS:
- *
- * The "Media Previous" item.
- * <inlinegraphic fileref="media-skip-backward-ltr.png" format="PNG"></inlinegraphic>
- * RTL variant
- * <inlinegraphic fileref="media-skip-backward-rtl.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.6
- *
- * Deprecated: 3.10: Use named icon "media-skip-backward" or the label "Pre_vious".
- */
-#define GTK_STOCK_MEDIA_PREVIOUS ((GtkStock)"gtk-media-previous")
-
-/**
- * GTK_STOCK_MEDIA_RECORD:
- *
- * The "Media Record" item.
- * <inlinegraphic fileref="media-record.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.6
- *
- * Deprecated: 3.10: Use named icon "media-record" or the label "_Record".
- */
-#define GTK_STOCK_MEDIA_RECORD ((GtkStock)"gtk-media-record")
-
-/**
- * GTK_STOCK_MEDIA_REWIND:
- *
- * The "Media Rewind" item.
- * <inlinegraphic fileref="media-seek-backward-ltr.png" format="PNG"></inlinegraphic>
- * RTL variant
- * <inlinegraphic fileref="media-seek-backward-rtl.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.6
- *
- * Deprecated: 3.10: Use named icon "media-seek-backward" or the label "R_ewind".
- */
-#define GTK_STOCK_MEDIA_REWIND ((GtkStock)"gtk-media-rewind")
-
-/**
- * GTK_STOCK_MEDIA_STOP:
- *
- * The "Media Stop" item.
- * <inlinegraphic fileref="media-playback-stop.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.6
- *
- * Deprecated: 3.10: Use named icon "media-playback-stop" or the label "_Stop".
- */
-#define GTK_STOCK_MEDIA_STOP ((GtkStock)"gtk-media-stop")
-
-/**
- * GTK_STOCK_NETWORK:
- *
- * The "Network" item.
- * <inlinegraphic fileref="network-idle.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.4
- *
- * Deprecated: 3.10: Use named icon "network-workgroup".
- */
-#define GTK_STOCK_NETWORK ((GtkStock)"gtk-network")
-
-/**
- * GTK_STOCK_NEW:
- *
- * The "New" item.
- * <inlinegraphic fileref="document-new.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "document-new" or the label "_New".
- */
-#define GTK_STOCK_NEW ((GtkStock)"gtk-new")
-
-/**
- * GTK_STOCK_NO:
- *
- * The "No" item.
- * <inlinegraphic fileref="gtk-no.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10
- */
-#define GTK_STOCK_NO ((GtkStock)"gtk-no")
-
-/**
- * GTK_STOCK_OK:
- *
- * The "OK" item.
- * <inlinegraphic fileref="gtk-ok.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Do not use an icon. Use label "_OK".
- */
-#define GTK_STOCK_OK ((GtkStock)"gtk-ok")
-
-/**
- * GTK_STOCK_OPEN:
- *
- * The "Open" item.
- * <inlinegraphic fileref="document-open.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "document-open" or the label "_Open".
- */
-#define GTK_STOCK_OPEN ((GtkStock)"gtk-open")
-
-/**
- * GTK_STOCK_ORIENTATION_PORTRAIT:
- *
- * The "Portrait Orientation" item.
- * <inlinegraphic fileref="gtk-orientation-portrait.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.10
- *
- * Deprecated: 3.10
- */
-#define GTK_STOCK_ORIENTATION_PORTRAIT ((GtkStock)"gtk-orientation-portrait")
-
-/**
- * GTK_STOCK_ORIENTATION_LANDSCAPE:
- *
- * The "Landscape Orientation" item.
- * <inlinegraphic fileref="gtk-orientation-landscape.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.10
- *
- * Deprecated: 3.10
- */
-#define GTK_STOCK_ORIENTATION_LANDSCAPE ((GtkStock)"gtk-orientation-landscape")
-
-/**
- * GTK_STOCK_ORIENTATION_REVERSE_LANDSCAPE:
- *
- * The "Reverse Landscape Orientation" item.
- * <inlinegraphic fileref="gtk-orientation-reverse-landscape.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.10
- *
- * Deprecated: 3.10
- */
-#define GTK_STOCK_ORIENTATION_REVERSE_LANDSCAPE ((GtkStock)"gtk-orientation-reverse-landscape")
-
-/**
- * GTK_STOCK_ORIENTATION_REVERSE_PORTRAIT:
- *
- * The "Reverse Portrait Orientation" item.
- * <inlinegraphic fileref="gtk-orientation-reverse-portrait.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.10
- *
- * Deprecated: 3.10
- */
-#define GTK_STOCK_ORIENTATION_REVERSE_PORTRAIT ((GtkStock)"gtk-orientation-reverse-portrait")
-
-/**
- * GTK_STOCK_PAGE_SETUP:
- *
- * The "Page Setup" item.
- * <inlinegraphic fileref="gtk-page-setup.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.14
- *
- * Deprecated: 3.10: Use named icon "document-page-setup" or the label "Page Set_up".
- */
-#define GTK_STOCK_PAGE_SETUP ((GtkStock)"gtk-page-setup")
-
-/**
- * GTK_STOCK_PASTE:
- *
- * The "Paste" item.
- * <inlinegraphic fileref="edit-paste.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Do not use an icon. Use label "_Paste".
- */
-#define GTK_STOCK_PASTE ((GtkStock)"gtk-paste")
-
-/**
- * GTK_STOCK_PREFERENCES:
- *
- * The "Preferences" item.
- * <inlinegraphic fileref="gtk-preferences.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "preferences-system" or the label "_Preferences".
- */
-#define GTK_STOCK_PREFERENCES ((GtkStock)"gtk-preferences")
-
-/**
- * GTK_STOCK_PRINT:
- *
- * The "Print" item.
- * <inlinegraphic fileref="document-print.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "document-print" or the label "_Print".
- */
-#define GTK_STOCK_PRINT ((GtkStock)"gtk-print")
-
-/**
- * GTK_STOCK_PRINT_ERROR:
- *
- * The "Print Error" icon.
- * <inlinegraphic fileref="printer-error.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.14
- *
- * Deprecated: 3.10: Use named icon "printer-error".
- */
-#define GTK_STOCK_PRINT_ERROR ((GtkStock)"gtk-print-error")
-
-/**
- * GTK_STOCK_PRINT_PAUSED:
- *
- * The "Print Paused" icon.
- * <inlinegraphic fileref="printer-paused.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.14
- *
- * Deprecated: 3.10
- */
-#define GTK_STOCK_PRINT_PAUSED ((GtkStock)"gtk-print-paused")
-
-/**
- * GTK_STOCK_PRINT_PREVIEW:
- *
- * The "Print Preview" item.
- * <inlinegraphic fileref="document-print-preview.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use label "Pre_view".
- */
-#define GTK_STOCK_PRINT_PREVIEW ((GtkStock)"gtk-print-preview")
-
-/**
- * GTK_STOCK_PRINT_REPORT:
- *
- * The "Print Report" icon.
- * <inlinegraphic fileref="printer-info.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.14
- *
- * Deprecated: 3.10
- */
-#define GTK_STOCK_PRINT_REPORT ((GtkStock)"gtk-print-report")
-
-
-/**
- * GTK_STOCK_PRINT_WARNING:
- *
- * The "Print Warning" icon.
- * <inlinegraphic fileref="printer-warning.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.14
- *
- * Deprecated: 3.10
- */
-#define GTK_STOCK_PRINT_WARNING ((GtkStock)"gtk-print-warning")
-
-/**
- * GTK_STOCK_PROPERTIES:
- *
- * The "Properties" item.
- * <inlinegraphic fileref="document-properties.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "document-properties" or the label "_Properties".
- */
-#define GTK_STOCK_PROPERTIES ((GtkStock)"gtk-properties")
-
-/**
- * GTK_STOCK_QUIT:
- *
- * The "Quit" item.
- * <inlinegraphic fileref="application-exit.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "application-exit" or the label "_Quit".
- */
-#define GTK_STOCK_QUIT ((GtkStock)"gtk-quit")
-
-/**
- * GTK_STOCK_REDO:
- *
- * The "Redo" item.
- * <inlinegraphic fileref="edit-redo-ltr.png" format="PNG"></inlinegraphic>
- * RTL variant
- * <inlinegraphic fileref="edit-redo-rtl.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "edit-redo" or the label "_Redo".
- */
-#define GTK_STOCK_REDO ((GtkStock)"gtk-redo")
-
-/**
- * GTK_STOCK_REFRESH:
- *
- * The "Refresh" item.
- * <inlinegraphic fileref="view-refresh.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "view-refresh" or the label "_Refresh".
- */
-#define GTK_STOCK_REFRESH ((GtkStock)"gtk-refresh")
-
-/**
- * GTK_STOCK_REMOVE:
- *
- * The "Remove" item.
- * <inlinegraphic fileref="list-remove.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "list-remove" or the label "_Remove".
- */
-#define GTK_STOCK_REMOVE ((GtkStock)"gtk-remove")
-
-/**
- * GTK_STOCK_REVERT_TO_SAVED:
- *
- * The "Revert" item.
- * <inlinegraphic fileref="document-revert-ltr.png" format="PNG"></inlinegraphic>
- * RTL variant
- * <inlinegraphic fileref="document-revert-rtl.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "document-revert" or the label "_Revert".
- */
-#define GTK_STOCK_REVERT_TO_SAVED ((GtkStock)"gtk-revert-to-saved")
-
-/**
- * GTK_STOCK_SAVE:
- *
- * The "Save" item.
- * <inlinegraphic fileref="document-save.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "document-save" or the label "_Save".
- */
-#define GTK_STOCK_SAVE ((GtkStock)"gtk-save")
-
-/**
- * GTK_STOCK_SAVE_AS:
- *
- * The "Save As" item.
- * <inlinegraphic fileref="document-save-as.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "document-save-as" or the label "Save _As".
- */
-#define GTK_STOCK_SAVE_AS ((GtkStock)"gtk-save-as")
-
-/**
- * GTK_STOCK_SELECT_ALL:
- *
- * The "Select All" item.
- * <inlinegraphic fileref="edit-select-all.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.10
- *
- * Deprecated: 3.10: Use named icon "edit-select-all" or the label "Select _All".
- */
-#define GTK_STOCK_SELECT_ALL ((GtkStock)"gtk-select-all")
-
-/**
- * GTK_STOCK_SELECT_COLOR:
- *
- * The "Color" item.
- * <inlinegraphic fileref="gtk-select-color.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10
- */
-#define GTK_STOCK_SELECT_COLOR ((GtkStock)"gtk-select-color")
-
-/**
- * GTK_STOCK_SELECT_FONT:
- *
- * The "Font" item.
- * <inlinegraphic fileref="gtk-font.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10
- */
-#define GTK_STOCK_SELECT_FONT ((GtkStock)"gtk-select-font")
-
-/**
- * GTK_STOCK_SORT_ASCENDING:
- *
- * The "Ascending" item.
- * <inlinegraphic fileref="view-sort-ascending.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "view-sort-ascending".
- */
-#define GTK_STOCK_SORT_ASCENDING ((GtkStock)"gtk-sort-ascending")
-
-/**
- * GTK_STOCK_SORT_DESCENDING:
- *
- * The "Descending" item.
- * <inlinegraphic fileref="view-sort-descending.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "view-sort-descending".
- */
-#define GTK_STOCK_SORT_DESCENDING ((GtkStock)"gtk-sort-descending")
-
-/**
- * GTK_STOCK_SPELL_CHECK:
- *
- * The "Spell Check" item.
- * <inlinegraphic fileref="tools-check-spelling.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "tools-check-spelling".
- */
-#define GTK_STOCK_SPELL_CHECK ((GtkStock)"gtk-spell-check")
-
-/**
- * GTK_STOCK_STOP:
- *
- * The "Stop" item.
- * <inlinegraphic fileref="process-stop.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "process-stop" or the label "_Stop".
- */
-#define GTK_STOCK_STOP ((GtkStock)"gtk-stop")
-
-/**
- * GTK_STOCK_STRIKETHROUGH:
- *
- * The "Strikethrough" item.
- * <inlinegraphic fileref="format-text-strikethrough.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "format-text-strikethrough" or the label "_Strikethrough".
- */
-#define GTK_STOCK_STRIKETHROUGH ((GtkStock)"gtk-strikethrough")
-
-/**
- * GTK_STOCK_UNDELETE:
- *
- * The "Undelete" item.
- * <inlinegraphic fileref="gtk-undelete-ltr.png" format="PNG"></inlinegraphic>
- * RTL variant
- * <inlinegraphic fileref="gtk-undelete-rtl.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10
- */
-#define GTK_STOCK_UNDELETE ((GtkStock)"gtk-undelete")
-
-/**
- * GTK_STOCK_UNDERLINE:
- *
- * The "Underline" item.
- * <inlinegraphic fileref="format-text-underline.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "format-text-underline" or the label "_Underline".
- */
-#define GTK_STOCK_UNDERLINE ((GtkStock)"gtk-underline")
-
-/**
- * GTK_STOCK_UNDO:
- *
- * The "Undo" item.
- * <inlinegraphic fileref="edit-undo-ltr.png" format="PNG"></inlinegraphic>
- * RTL variant
- * <inlinegraphic fileref="edit-undo-rtl.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "edit-undo" or the label "_Undo".
- */
-#define GTK_STOCK_UNDO ((GtkStock)"gtk-undo")
-
-/**
- * GTK_STOCK_UNINDENT:
- *
- * The "Unindent" item.
- * <inlinegraphic fileref="format-indent-less-ltr.png" format="PNG"></inlinegraphic>
- * RTL variant
- * <inlinegraphic fileref="format-indent-less-rtl.png" format="PNG"></inlinegraphic>
- *
- * Since: 2.4
- *
- * Deprecated: 3.10: Use named icon "format-indent-less".
- */
-#define GTK_STOCK_UNINDENT ((GtkStock)"gtk-unindent")
-
-/**
- * GTK_STOCK_YES:
- *
- * The "Yes" item.
- * <inlinegraphic fileref="gtk-yes.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10
- */
-#define GTK_STOCK_YES ((GtkStock)"gtk-yes")
-
-/**
- * GTK_STOCK_ZOOM_100:
- *
- * The "Zoom 100%" item.
- * <inlinegraphic fileref="zoom-original.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "zoom-original" or the label "_Normal Size".
- */
-#define GTK_STOCK_ZOOM_100 ((GtkStock)"gtk-zoom-100")
-
-/**
- * GTK_STOCK_ZOOM_FIT:
- *
- * The "Zoom to Fit" item.
- * <inlinegraphic fileref="zoom-fit-best.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "zoom-fit-best" or the label "Best _Fit".
- */
-#define GTK_STOCK_ZOOM_FIT ((GtkStock)"gtk-zoom-fit")
-
-/**
- * GTK_STOCK_ZOOM_IN:
- *
- * The "Zoom In" item.
- * <inlinegraphic fileref="zoom-in.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "zoom-in" or the label "Zoom _In".
- */
-#define GTK_STOCK_ZOOM_IN ((GtkStock)"gtk-zoom-in")
-
-/**
- * GTK_STOCK_ZOOM_OUT:
- *
- * The "Zoom Out" item.
- * <inlinegraphic fileref="zoom-out.png" format="PNG"></inlinegraphic>
- *
- * Deprecated: 3.10: Use named icon "zoom-out" or the label "Zoom _Out".
- */
-#define GTK_STOCK_ZOOM_OUT ((GtkStock)"gtk-zoom-out")
-
-G_END_DECLS
-
-#endif /* __GTK_STOCK_H__ */
#include "gtkwidget.h"
#include "gtkwindow.h"
#include "gtkprivate.h"
-#include "gtkiconfactory.h"
+#include "deprecated/gtkiconfactory.h"
#include "gtkwidgetpath.h"
#include "gtkwidgetprivate.h"
#include "gtkstylecascadeprivate.h"
#include <glib-object.h>
#include <gtk/gtkenums.h>
-#include <gtk/gtkiconfactory.h>
+#include <gtk/deprecated/gtkiconfactory.h>
#include <gtk/gtkstyleproperties.h>
#include <gtk/gtktypes.h>
#include "gtkswitch.h"
-#include "gtkactivatable.h"
+#include "deprecated/gtkactivatable.h"
#include "gtkintl.h"
#include "gtkprivate.h"
-#include "gtktoggleaction.h"
+#include "deprecated/gtktoggleaction.h"
#include "gtkwidget.h"
#include "gtkmarshalers.h"
#include "gtkapplicationprivate.h"
#define GTK_TEXT_USE_INTERNAL_UNSUPPORTED_API
#include "gtkbindings.h"
#include "gtkdnd.h"
-#include "gtkimagemenuitem.h"
+#include "deprecated/gtkimagemenuitem.h"
#include "gtkintl.h"
#include "gtkmain.h"
#include "gtkmarshalers.h"
+++ /dev/null
-/*
- * GTK - The GIMP Toolkit
- * Copyright (C) 1998, 1999 Red Hat, Inc.
- * All rights reserved.
- *
- * This Library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This Library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Author: James Henstridge <james@daa.com.au>
- *
- * Modified by the GTK+ Team and others 2003. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#include "config.h"
-
-#define GDK_DISABLE_DEPRECATION_WARNINGS
-
-#include "gtkintl.h"
-#include "gtktoggleaction.h"
-#include "gtktoggletoolbutton.h"
-#include "gtktogglebutton.h"
-#include "gtkcheckmenuitem.h"
-#include "gtkprivate.h"
-
-
-/**
- * SECTION:gtktoggleaction
- * @Short_description: An action which can be toggled between two states
- * @Title: GtkToggleAction
- *
- * A #GtkToggleAction corresponds roughly to a #GtkCheckMenuItem. It has an
- * "active" state specifying whether the action has been checked or not.
- */
-
-struct _GtkToggleActionPrivate
-{
- guint active : 1;
- guint draw_as_radio : 1;
-};
-
-enum
-{
- TOGGLED,
- LAST_SIGNAL
-};
-
-enum {
- PROP_0,
- PROP_DRAW_AS_RADIO,
- PROP_ACTIVE
-};
-
-G_DEFINE_TYPE_WITH_PRIVATE (GtkToggleAction, gtk_toggle_action, GTK_TYPE_ACTION)
-
-static void gtk_toggle_action_activate (GtkAction *action);
-static void set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static GtkWidget *create_menu_item (GtkAction *action);
-
-
-static GObjectClass *parent_class = NULL;
-static guint action_signals[LAST_SIGNAL] = { 0 };
-
-static void
-gtk_toggle_action_class_init (GtkToggleActionClass *klass)
-{
- GObjectClass *gobject_class;
- GtkActionClass *action_class;
-
- parent_class = g_type_class_peek_parent (klass);
- gobject_class = G_OBJECT_CLASS (klass);
- action_class = GTK_ACTION_CLASS (klass);
-
- gobject_class->set_property = set_property;
- gobject_class->get_property = get_property;
-
- action_class->activate = gtk_toggle_action_activate;
-
- action_class->menu_item_type = GTK_TYPE_CHECK_MENU_ITEM;
- action_class->toolbar_item_type = GTK_TYPE_TOGGLE_TOOL_BUTTON;
-
- action_class->create_menu_item = create_menu_item;
-
- klass->toggled = NULL;
-
- /**
- * GtkToggleAction:draw-as-radio:
- *
- * Whether the proxies for this action look like radio action proxies.
- *
- * This is an appearance property and thus only applies if
- * #GtkActivatable:use-action-appearance is %TRUE.
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_DRAW_AS_RADIO,
- g_param_spec_boolean ("draw-as-radio",
- P_("Create the same proxies as a radio action"),
- P_("Whether the proxies for this action look like radio action proxies"),
- FALSE,
- GTK_PARAM_READWRITE));
-
- /**
- * GtkToggleAction:active:
- *
- * Whether the toggle action should be active.
- *
- * Since: 2.10
- *
- * Deprecated: 3.10
- */
- g_object_class_install_property (gobject_class,
- PROP_ACTIVE,
- g_param_spec_boolean ("active",
- P_("Active"),
- P_("Whether the toggle action should be active"),
- FALSE,
- GTK_PARAM_READWRITE));
- /**
- * GtkToggleAction::toggled:
- * @toggleaction: the object which received the signal.
- *
- * Should be connected if you wish to perform an action
- * whenever the #GtkToggleAction state is changed.
- *
- * Deprecated: 3.10
- */
- action_signals[TOGGLED] =
- g_signal_new (I_("toggled"),
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GtkToggleActionClass, toggled),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-static void
-gtk_toggle_action_init (GtkToggleAction *action)
-{
- action->private_data = gtk_toggle_action_get_instance_private (action);
- action->private_data->active = FALSE;
- action->private_data->draw_as_radio = FALSE;
-}
-
-/**
- * gtk_toggle_action_new:
- * @name: A unique name for the action
- * @label: (allow-none): The label displayed in menu items and on buttons,
- * or %NULL
- * @tooltip: (allow-none): A tooltip for the action, or %NULL
- * @stock_id: (allow-none): The stock icon to display in widgets representing
- * the action, or %NULL
- *
- * Creates a new #GtkToggleAction object. To add the action to
- * a #GtkActionGroup and set the accelerator for the action,
- * call gtk_action_group_add_action_with_accel().
- *
- * Return value: a new #GtkToggleAction
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-GtkToggleAction *
-gtk_toggle_action_new (const gchar *name,
- const gchar *label,
- const gchar *tooltip,
- const gchar *stock_id)
-{
- g_return_val_if_fail (name != NULL, NULL);
-
- return g_object_new (GTK_TYPE_TOGGLE_ACTION,
- "name", name,
- "label", label,
- "tooltip", tooltip,
- "stock-id", stock_id,
- NULL);
-}
-
-static void
-get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GtkToggleAction *action = GTK_TOGGLE_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_DRAW_AS_RADIO:
- g_value_set_boolean (value, gtk_toggle_action_get_draw_as_radio (action));
- break;
- case PROP_ACTIVE:
- g_value_set_boolean (value, gtk_toggle_action_get_active (action));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GtkToggleAction *action = GTK_TOGGLE_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_DRAW_AS_RADIO:
- gtk_toggle_action_set_draw_as_radio (action, g_value_get_boolean (value));
- break;
- case PROP_ACTIVE:
- gtk_toggle_action_set_active (action, g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gtk_toggle_action_activate (GtkAction *action)
-{
- GtkToggleAction *toggle_action;
-
- g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
-
- toggle_action = GTK_TOGGLE_ACTION (action);
-
- toggle_action->private_data->active = !toggle_action->private_data->active;
-
- g_object_notify (G_OBJECT (action), "active");
-
- gtk_toggle_action_toggled (toggle_action);
-}
-
-/**
- * gtk_toggle_action_toggled:
- * @action: the action object
- *
- * Emits the "toggled" signal on the toggle action.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-void
-gtk_toggle_action_toggled (GtkToggleAction *action)
-{
- g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
-
- g_signal_emit (action, action_signals[TOGGLED], 0);
-}
-
-/**
- * gtk_toggle_action_set_active:
- * @action: the action object
- * @is_active: whether the action should be checked or not
- *
- * Sets the checked state on the toggle action.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-void
-gtk_toggle_action_set_active (GtkToggleAction *action,
- gboolean is_active)
-{
- g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
-
- is_active = is_active != FALSE;
-
- if (action->private_data->active != is_active)
- _gtk_action_emit_activate (GTK_ACTION (action));
-}
-
-/**
- * gtk_toggle_action_get_active:
- * @action: the action object
- *
- * Returns the checked state of the toggle action.
- *
- * Returns: the checked state of the toggle action
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-gboolean
-gtk_toggle_action_get_active (GtkToggleAction *action)
-{
- g_return_val_if_fail (GTK_IS_TOGGLE_ACTION (action), FALSE);
-
- return action->private_data->active;
-}
-
-
-/**
- * gtk_toggle_action_set_draw_as_radio:
- * @action: the action object
- * @draw_as_radio: whether the action should have proxies like a radio
- * action
- *
- * Sets whether the action should have proxies like a radio action.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-void
-gtk_toggle_action_set_draw_as_radio (GtkToggleAction *action,
- gboolean draw_as_radio)
-{
- g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
-
- draw_as_radio = draw_as_radio != FALSE;
-
- if (action->private_data->draw_as_radio != draw_as_radio)
- {
- action->private_data->draw_as_radio = draw_as_radio;
-
- g_object_notify (G_OBJECT (action), "draw-as-radio");
- }
-}
-
-/**
- * gtk_toggle_action_get_draw_as_radio:
- * @action: the action object
- *
- * Returns whether the action should have proxies like a radio action.
- *
- * Returns: whether the action should have proxies like a radio action.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
-gboolean
-gtk_toggle_action_get_draw_as_radio (GtkToggleAction *action)
-{
- g_return_val_if_fail (GTK_IS_TOGGLE_ACTION (action), FALSE);
-
- return action->private_data->draw_as_radio;
-}
-
-static GtkWidget *
-create_menu_item (GtkAction *action)
-{
- GtkToggleAction *toggle_action = GTK_TOGGLE_ACTION (action);
-
- return g_object_new (GTK_TYPE_CHECK_MENU_ITEM,
- "draw-as-radio", toggle_action->private_data->draw_as_radio,
- NULL);
-}
-
-
-/* Private */
-
-/*
- * _gtk_toggle_action_set_active:
- * @toggle_action: a #GtkToggleAction
- * @is_active: whether the action is active or not
- *
- * Sets the #GtkToggleAction:active property directly. This function does
- * not emit signals or notifications: it is left to the caller to do so.
- *
- * Deprecated: 3.10
- */
-void
-_gtk_toggle_action_set_active (GtkToggleAction *toggle_action,
- gboolean is_active)
-{
- GtkToggleActionPrivate *priv = toggle_action->private_data;
-
- priv->active = is_active;
-}
+++ /dev/null
-/*
- * GTK - The GIMP Toolkit
- * Copyright (C) 1998, 1999 Red Hat, Inc.
- * All rights reserved.
- *
- * This Library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This Library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Author: James Henstridge <james@daa.com.au>
- *
- * Modified by the GTK+ Team and others 2003. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#ifndef __GTK_TOGGLE_ACTION_H__
-#define __GTK_TOGGLE_ACTION_H__
-
-#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
-#error "Only <gtk/gtk.h> can be included directly."
-#endif
-
-#include <gtk/gtkaction.h>
-
-G_BEGIN_DECLS
-
-#define GTK_TYPE_TOGGLE_ACTION (gtk_toggle_action_get_type ())
-#define GTK_TOGGLE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TOGGLE_ACTION, GtkToggleAction))
-#define GTK_TOGGLE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TOGGLE_ACTION, GtkToggleActionClass))
-#define GTK_IS_TOGGLE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TOGGLE_ACTION))
-#define GTK_IS_TOGGLE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TOGGLE_ACTION))
-#define GTK_TOGGLE_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_TOGGLE_ACTION, GtkToggleActionClass))
-
-typedef struct _GtkToggleAction GtkToggleAction;
-typedef struct _GtkToggleActionPrivate GtkToggleActionPrivate;
-typedef struct _GtkToggleActionClass GtkToggleActionClass;
-
-struct _GtkToggleAction
-{
- GtkAction parent;
-
- /*< private >*/
- GtkToggleActionPrivate *private_data;
-};
-
-struct _GtkToggleActionClass
-{
- GtkActionClass parent_class;
-
- void (* toggled) (GtkToggleAction *action);
-
- /* Padding for future expansion */
- void (*_gtk_reserved1) (void);
- void (*_gtk_reserved2) (void);
- void (*_gtk_reserved3) (void);
- void (*_gtk_reserved4) (void);
-};
-
-GDK_DEPRECATED_IN_3_10
-GType gtk_toggle_action_get_type (void) G_GNUC_CONST;
-GDK_DEPRECATED_IN_3_10
-GtkToggleAction *gtk_toggle_action_new (const gchar *name,
- const gchar *label,
- const gchar *tooltip,
- const gchar *stock_id);
-GDK_DEPRECATED_IN_3_10
-void gtk_toggle_action_toggled (GtkToggleAction *action);
-GDK_DEPRECATED_IN_3_10
-void gtk_toggle_action_set_active (GtkToggleAction *action,
- gboolean is_active);
-GDK_DEPRECATED_IN_3_10
-gboolean gtk_toggle_action_get_active (GtkToggleAction *action);
-GDK_DEPRECATED_IN_3_10
-void gtk_toggle_action_set_draw_as_radio (GtkToggleAction *action,
- gboolean draw_as_radio);
-GDK_DEPRECATED_IN_3_10
-gboolean gtk_toggle_action_get_draw_as_radio (GtkToggleAction *action);
-
-/* private */
-void _gtk_toggle_action_set_active (GtkToggleAction *toggle_action,
- gboolean is_active);
-
-
-G_END_DECLS
-
-#endif /* __GTK_TOGGLE_ACTION_H__ */
#include "gtklabel.h"
#include "gtkmain.h"
#include "gtkmarshalers.h"
-#include "gtktoggleaction.h"
-#include "gtkactivatable.h"
+#include "deprecated/gtktoggleaction.h"
+#include "deprecated/gtkactivatable.h"
#include "gtkprivate.h"
#include "gtkintl.h"
#include "a11y/gtktogglebuttonaccessible.h"
#include "gtkcheckmenuitem.h"
#include "gtklabel.h"
#include "gtktogglebutton.h"
-#include "gtkstock.h"
+#include "deprecated/gtkstock.h"
#include "gtkintl.h"
#include "gtkradiotoolbutton.h"
-#include "gtktoggleaction.h"
-#include "gtkactivatable.h"
+#include "deprecated/gtktoggleaction.h"
+#include "deprecated/gtkactivatable.h"
#include "gtkprivate.h"
#include "gtkradiotoolbutton.h"
#include "gtkseparatormenuitem.h"
#include "gtkseparatortoolitem.h"
-#include "gtkstock.h"
+#include "deprecated/gtkstock.h"
#include "gtktoolshell.h"
#include "gtkbox.h"
#include "gtkprivate.h"
#include "config.h"
#include "gtktoolbutton.h"
#include "gtkbutton.h"
-#include "gtkiconfactory.h"
+#include "deprecated/gtkiconfactory.h"
#include "gtkimage.h"
-#include "gtkimagemenuitem.h"
+#include "deprecated/gtkimagemenuitem.h"
#include "gtklabel.h"
-#include "gtkstock.h"
+#include "deprecated/gtkstock.h"
#include "gtkbox.h"
#include "gtkintl.h"
#include "gtktoolbar.h"
-#include "gtkactivatable.h"
+#include "deprecated/gtkactivatable.h"
#include "gtkactionable.h"
#include "gtkprivate.h"
#include "gtktoolshell.h"
#include "gtkseparatormenuitem.h"
#include "gtksizerequest.h"
-#include "gtkactivatable.h"
+#include "deprecated/gtkactivatable.h"
#include "gtkintl.h"
#include "gtkprivate.h"
+++ /dev/null
-/*
- * GTK - The GIMP Toolkit
- * Copyright (C) 1998, 1999 Red Hat, Inc.
- * All rights reserved.
- *
- * This Library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This Library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Author: James Henstridge <james@daa.com.au>
- *
- * Modified by the GTK+ Team and others 2003. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#include "config.h"
-
-#define GDK_DISABLE_DEPRECATION_WARNINGS
-
-#include <string.h>
-#include "gtkaccellabel.h"
-#include "gtkactivatable.h"
-#include "gtkbuildable.h"
-#include "gtkimagemenuitem.h"
-#include "gtkintl.h"
-#include "gtkmarshalers.h"
-#include "gtkmenu.h"
-#include "gtkmenushellprivate.h"
-#include "gtkmenubar.h"
-#include "gtkmenutoolbutton.h"
-#include "gtkseparatormenuitem.h"
-#include "gtkseparatortoolitem.h"
-#include "gtktoolbar.h"
-#include "gtkwindow.h"
-#include "gtkprivate.h"
-
-#include "gtkuimanager.h"
-#include "deprecated/gtktearoffmenuitem.h"
-
-/**
- * SECTION:gtkuimanager
- * @Short_description: Constructing menus and toolbars from an XML description
- * @Title: GtkUIManager
- * @See_also:#GtkBuilder
- *
- * A #GtkUIManager constructs a user interface (menus and toolbars) from
- * one or more UI definitions, which reference actions from one or more
- * action groups.
- *
- * <refsect2 id="XML-UI">
- * <title>UI Definitions</title>
- * <para>
- * The UI definitions are specified in an XML format which can be
- * roughly described by the following DTD.
- *
- * <note><para>
- * Do not confuse the GtkUIManager UI Definitions described here with
- * the similarly named <link linkend="BUILDER-UI">GtkBuilder UI
- * Definitions</link>.
- * </para></note>
- *
- * <programlisting>
- * <![CDATA[
- * <!ELEMENT ui (menubar|toolbar|popup|accelerator)* >
- * <!ELEMENT menubar (menuitem|separator|placeholder|menu)* >
- * <!ELEMENT menu (menuitem|separator|placeholder|menu)* >
- * <!ELEMENT popup (menuitem|separator|placeholder|menu)* >
- * <!ELEMENT toolbar (toolitem|separator|placeholder)* >
- * <!ELEMENT placeholder (menuitem|toolitem|separator|placeholder|menu)* >
- * <!ELEMENT menuitem EMPTY >
- * <!ELEMENT toolitem (menu?) >
- * <!ELEMENT separator EMPTY >
- * <!ELEMENT accelerator EMPTY >
- * <!ATTLIST menubar name #IMPLIED
- * action #IMPLIED >
- * <!ATTLIST toolbar name #IMPLIED
- * action #IMPLIED >
- * <!ATTLIST popup name #IMPLIED
- * action #IMPLIED
- * accelerators (true|false) #IMPLIED >
- * <!ATTLIST placeholder name #IMPLIED
- * action #IMPLIED >
- * <!ATTLIST separator name #IMPLIED
- * action #IMPLIED
- * expand (true|false) #IMPLIED >
- * <!ATTLIST menu name #IMPLIED
- * action #REQUIRED
- * position (top|bot) #IMPLIED >
- * <!ATTLIST menuitem name #IMPLIED
- * action #REQUIRED
- * position (top|bot) #IMPLIED
- * always-show-image (true|false) #IMPLIED >
- * <!ATTLIST toolitem name #IMPLIED
- * action #REQUIRED
- * position (top|bot) #IMPLIED >
- * <!ATTLIST accelerator name #IMPLIED
- * action #REQUIRED >
- * ]]>
- * </programlisting>
- * There are some additional restrictions beyond those specified in the
- * DTD, e.g. every toolitem must have a toolbar in its anchestry and
- * every menuitem must have a menubar or popup in its anchestry. Since
- * a #GMarkup parser is used to parse the UI description, it must not only
- * be valid XML, but valid #GMarkup.
- *
- * If a name is not specified, it defaults to the action. If an action is
- * not specified either, the element name is used. The name and action
- * attributes must not contain '/' characters after parsing (since that
- * would mess up path lookup) and must be usable as XML attributes when
- * enclosed in doublequotes, thus they must not '"' characters or references
- * to the " entity.
- *
- * <example>
- * <title>A UI definition</title>
- * <programlisting><![CDATA[
- * <ui>
- * <menubar>
- * <menu name="FileMenu" action="FileMenuAction">
- * <menuitem name="New" action="New2Action" />
- * <placeholder name="FileMenuAdditions" />
- * </menu>
- * <menu name="JustifyMenu" action="JustifyMenuAction">
- * <menuitem name="Left" action="justify-left"/>
- * <menuitem name="Centre" action="justify-center"/>
- * <menuitem name="Right" action="justify-right"/>
- * <menuitem name="Fill" action="justify-fill"/>
- * </menu>
- * </menubar>
- * <toolbar action="toolbar1">
- * <placeholder name="JustifyToolItems">
- * <separator/>
- * <toolitem name="Left" action="justify-left"/>
- * <toolitem name="Centre" action="justify-center"/>
- * <toolitem name="Right" action="justify-right"/>
- * <toolitem name="Fill" action="justify-fill"/>
- * <separator/>
- * </placeholder>
- * </toolbar>
- * </ui>
- * ]]></programlisting>
- * </example>
- *
- * The constructed widget hierarchy is very similar to the element tree
- * of the XML, with the exception that placeholders are merged into their
- * parents. The correspondence of XML elements to widgets should be
- * almost obvious:
- * <variablelist>
- * <varlistentry>
- * <term>menubar</term>
- * <listitem><para>a #GtkMenuBar</para></listitem>
- * </varlistentry>
- * <varlistentry>
- * <term>toolbar</term>
- * <listitem><para>a #GtkToolbar</para></listitem>
- * </varlistentry>
- * <varlistentry>
- * <term>popup</term>
- * <listitem><para>a toplevel #GtkMenu</para></listitem>
- * </varlistentry>
- * <varlistentry>
- * <term>menu</term>
- * <listitem><para>a #GtkMenu attached to a menuitem</para></listitem>
- * </varlistentry>
- * <varlistentry>
- * <term>menuitem</term>
- * <listitem><para>a #GtkMenuItem subclass, the exact type depends on the
- * action</para></listitem>
- * </varlistentry>
- * <varlistentry>
- * <term>toolitem</term>
- * <listitem><para>a #GtkToolItem subclass, the exact type depends on the
- * action. Note that toolitem elements may contain a menu element, but only
- * if their associated action specifies a #GtkMenuToolButton as proxy.</para></listitem>
- * </varlistentry>
- * <varlistentry>
- * <term>separator</term>
- * <listitem><para>a #GtkSeparatorMenuItem or
- * #GtkSeparatorToolItem</para></listitem>
- * </varlistentry>
- * <varlistentry>
- * <term>accelerator</term>
- * <listitem><para>a keyboard accelerator</para></listitem>
- * </varlistentry>
- * </variablelist>
- *
- * The "position" attribute determines where a constructed widget is positioned
- * wrt. to its siblings in the partially constructed tree. If it is
- * "top", the widget is prepended, otherwise it is appended.
- * </para>
- * </refsect2>
- * <refsect2 id="UI-Merging">
- * <title>UI Merging</title>
- * <para>
- * The most remarkable feature of #GtkUIManager is that it can overlay a set
- * of menuitems and toolitems over another one, and demerge them later.
- *
- * Merging is done based on the names of the XML elements. Each element is
- * identified by a path which consists of the names of its anchestors, separated
- * by slashes. For example, the menuitem named "Left" in the example above
- * has the path <literal>/ui/menubar/JustifyMenu/Left</literal> and the
- * toolitem with the same name has path
- * <literal>/ui/toolbar1/JustifyToolItems/Left</literal>.
- * </para>
- * </refsect2>
- * <refsect2>
- * <title>Accelerators</title>
- * <para>
- * Every action has an accelerator path. Accelerators are installed together with
- * menuitem proxies, but they can also be explicitly added with <accelerator>
- * elements in the UI definition. This makes it possible to have accelerators for
- * actions even if they have no visible proxies.
- * </para>
- * </refsect2>
- * <refsect2 id="Smart-Separators">
- * <title>Smart Separators</title>
- * <para>
- * The separators created by #GtkUIManager are "smart", i.e. they do not show up
- * in the UI unless they end up between two visible menu or tool items. Separators
- * which are located at the very beginning or end of the menu or toolbar
- * containing them, or multiple separators next to each other, are hidden. This
- * is a useful feature, since the merging of UI elements from multiple sources
- * can make it hard or impossible to determine in advance whether a separator
- * will end up in such an unfortunate position.
- *
- * For separators in toolbars, you can set <literal>expand="true"</literal> to
- * turn them from a small, visible separator to an expanding, invisible one.
- * Toolitems following an expanding separator are effectively right-aligned.
- * </para>
- * </refsect2>
- * <refsect2>
- * <title>Empty Menus</title>
- * <para>
- * Submenus pose similar problems to separators inconnection with merging. It is
- * impossible to know in advance whether they will end up empty after merging.
- * #GtkUIManager offers two ways to treat empty submenus:
- * <itemizedlist>
- * <listitem>
- * <para>make them disappear by hiding the menu item they're attached to</para>
- * </listitem>
- * <listitem>
- * <para>add an insensitive "Empty" item</para>
- * </listitem>
- * </itemizedlist>
- * The behaviour is chosen based on the "hide_if_empty" property of the action
- * to which the submenu is associated.
- * </para>
- * </refsect2>
- * <refsect2 id="GtkUIManager-BUILDER-UI">
- * <title>GtkUIManager as GtkBuildable</title>
- * <para>
- * The GtkUIManager implementation of the GtkBuildable interface accepts
- * GtkActionGroup objects as <child> elements in UI definitions.
- *
- * A GtkUIManager UI definition as described above can be embedded in
- * an GtkUIManager <object> element in a GtkBuilder UI definition.
- *
- * The widgets that are constructed by a GtkUIManager can be embedded in
- * other parts of the constructed user interface with the help of the
- * "constructor" attribute. See the example below.
- *
- * <example>
- * <title>An embedded GtkUIManager UI definition</title>
- * <programlisting><![CDATA[
- * <object class="GtkUIManager" id="uiman">
- * <child>
- * <object class="GtkActionGroup" id="actiongroup">
- * <child>
- * <object class="GtkAction" id="file">
- * <property name="label">_File</property>
- * </object>
- * </child>
- * </object>
- * </child>
- * <ui>
- * <menubar name="menubar1">
- * <menu action="file">
- * </menu>
- * </menubar>
- * </ui>
- * </object>
- * <object class="GtkWindow" id="main-window">
- * <child>
- * <object class="GtkMenuBar" id="menubar1" constructor="uiman"/>
- * </child>
- * </object>
- * ]]></programlisting>
- * </example>
- * </para>
- * </refsect2>
- */
-
-
-#undef DEBUG_UI_MANAGER
-
-typedef enum
-{
- NODE_TYPE_UNDECIDED,
- NODE_TYPE_ROOT,
- NODE_TYPE_MENUBAR,
- NODE_TYPE_MENU,
- NODE_TYPE_TOOLBAR,
- NODE_TYPE_MENU_PLACEHOLDER,
- NODE_TYPE_TOOLBAR_PLACEHOLDER,
- NODE_TYPE_POPUP,
- NODE_TYPE_MENUITEM,
- NODE_TYPE_TOOLITEM,
- NODE_TYPE_SEPARATOR,
- NODE_TYPE_ACCELERATOR
-} NodeType;
-
-typedef struct _Node Node;
-
-struct _Node {
- NodeType type;
-
- gchar *name;
-
- GQuark action_name;
- GtkAction *action;
- GtkWidget *proxy;
- GtkWidget *extra; /* second separator for placeholders */
-
- GList *uifiles;
-
- guint dirty : 1;
- guint expand : 1; /* used for separators */
- guint popup_accels : 1;
- guint always_show_image_set : 1; /* used for menu items */
- guint always_show_image : 1; /* used for menu items */
-};
-
-
-struct _GtkUIManagerPrivate
-{
- GtkAccelGroup *accel_group;
-
- GNode *root_node;
- GList *action_groups;
-
- guint last_merge_id;
-
- guint update_tag;
-
- gboolean add_tearoffs;
-};
-
-#define NODE_INFO(node) ((Node *)node->data)
-
-typedef struct _NodeUIReference NodeUIReference;
-
-struct _NodeUIReference
-{
- guint merge_id;
- GQuark action_quark;
-};
-
-static void gtk_ui_manager_finalize (GObject *object);
-static void gtk_ui_manager_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gtk_ui_manager_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static GtkWidget * gtk_ui_manager_real_get_widget (GtkUIManager *manager,
- const gchar *path);
-static GtkAction * gtk_ui_manager_real_get_action (GtkUIManager *manager,
- const gchar *path);
-static void queue_update (GtkUIManager *manager);
-static void dirty_all_nodes (GtkUIManager *manager);
-static void mark_node_dirty (GNode *node);
-static GNode * get_child_node (GtkUIManager *manager,
- GNode *parent,
- GNode *sibling,
- const gchar *childname,
- gint childname_length,
- NodeType node_type,
- gboolean create,
- gboolean top);
-static GNode * get_node (GtkUIManager *manager,
- const gchar *path,
- NodeType node_type,
- gboolean create);
-static gboolean free_node (GNode *node);
-static void node_prepend_ui_reference (GNode *node,
- guint merge_id,
- GQuark action_quark);
-static void node_remove_ui_reference (GNode *node,
- guint merge_id);
-
-/* GtkBuildable */
-static void gtk_ui_manager_buildable_init (GtkBuildableIface *iface);
-static void gtk_ui_manager_buildable_add_child (GtkBuildable *buildable,
- GtkBuilder *builder,
- GObject *child,
- const gchar *type);
-static GObject* gtk_ui_manager_buildable_construct_child (GtkBuildable *buildable,
- GtkBuilder *builder,
- const gchar *name);
-static gboolean gtk_ui_manager_buildable_custom_tag_start (GtkBuildable *buildable,
- GtkBuilder *builder,
- GObject *child,
- const gchar *tagname,
- GMarkupParser *parser,
- gpointer *data);
-static void gtk_ui_manager_buildable_custom_tag_end (GtkBuildable *buildable,
- GtkBuilder *builder,
- GObject *child,
- const gchar *tagname,
- gpointer *data);
-static void gtk_ui_manager_do_set_add_tearoffs (GtkUIManager *manager,
- gboolean add_tearoffs);
-
-
-
-enum
-{
- ADD_WIDGET,
- ACTIONS_CHANGED,
- CONNECT_PROXY,
- DISCONNECT_PROXY,
- PRE_ACTIVATE,
- POST_ACTIVATE,
- LAST_SIGNAL
-};
-
-enum
-{
- PROP_0,
- PROP_ADD_TEAROFFS,
- PROP_UI
-};
-
-static guint ui_manager_signals[LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE_WITH_CODE (GtkUIManager, gtk_ui_manager, G_TYPE_OBJECT,
- G_ADD_PRIVATE (GtkUIManager)
- G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
- gtk_ui_manager_buildable_init))
-
-static void
-gtk_ui_manager_class_init (GtkUIManagerClass *klass)
-{
- GObjectClass *gobject_class;
-
- gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->finalize = gtk_ui_manager_finalize;
- gobject_class->set_property = gtk_ui_manager_set_property;
- gobject_class->get_property = gtk_ui_manager_get_property;
- klass->get_widget = gtk_ui_manager_real_get_widget;
- klass->get_action = gtk_ui_manager_real_get_action;
-
- /**
- * GtkUIManager:add-tearoffs:
- *
- * The "add-tearoffs" property controls whether generated menus
- * have tearoff menu items.
- *
- * Note that this only affects regular menus. Generated popup
- * menus never have tearoff menu items.
- *
- * Since: 2.4
- *
- * Deprecated: 3.4: Tearoff menus are deprecated and should not
- * be used in newly written code.
- */
- g_object_class_install_property (gobject_class,
- PROP_ADD_TEAROFFS,
- g_param_spec_boolean ("add-tearoffs",
- P_("Add tearoffs to menus"),
- P_("Whether tearoff menu items should be added to menus"),
- FALSE,
- GTK_PARAM_READWRITE | G_PARAM_DEPRECATED));
-
- g_object_class_install_property (gobject_class,
- PROP_UI,
- g_param_spec_string ("ui",
- P_("Merged UI definition"),
- P_("An XML string describing the merged UI"),
- "<ui>\n</ui>\n",
- GTK_PARAM_READABLE));
-
-
- /**
- * GtkUIManager::add-widget:
- * @manager: a #GtkUIManager
- * @widget: the added widget
- *
- * The ::add-widget signal is emitted for each generated menubar and toolbar.
- * It is not emitted for generated popup menus, which can be obtained by
- * gtk_ui_manager_get_widget().
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
- ui_manager_signals[ADD_WIDGET] =
- g_signal_new (I_("add-widget"),
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
- G_STRUCT_OFFSET (GtkUIManagerClass, add_widget),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- GTK_TYPE_WIDGET);
-
- /**
- * GtkUIManager::actions-changed:
- * @manager: a #GtkUIManager
- *
- * The ::actions-changed signal is emitted whenever the set of actions
- * changes.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
- ui_manager_signals[ACTIONS_CHANGED] =
- g_signal_new (I_("actions-changed"),
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
- G_STRUCT_OFFSET (GtkUIManagerClass, actions_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- /**
- * GtkUIManager::connect-proxy:
- * @manager: the ui manager
- * @action: the action
- * @proxy: the proxy
- *
- * The ::connect-proxy signal is emitted after connecting a proxy to
- * an action in the group.
- *
- * This is intended for simple customizations for which a custom action
- * class would be too clumsy, e.g. showing tooltips for menuitems in the
- * statusbar.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
- ui_manager_signals[CONNECT_PROXY] =
- g_signal_new (I_("connect-proxy"),
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
- G_STRUCT_OFFSET (GtkUIManagerClass, connect_proxy),
- NULL, NULL,
- _gtk_marshal_VOID__OBJECT_OBJECT,
- G_TYPE_NONE, 2,
- GTK_TYPE_ACTION,
- GTK_TYPE_WIDGET);
-
- /**
- * GtkUIManager::disconnect-proxy:
- * @manager: the ui manager
- * @action: the action
- * @proxy: the proxy
- *
- * The ::disconnect-proxy signal is emitted after disconnecting a proxy
- * from an action in the group.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
- ui_manager_signals[DISCONNECT_PROXY] =
- g_signal_new (I_("disconnect-proxy"),
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
- G_STRUCT_OFFSET (GtkUIManagerClass, disconnect_proxy),
- NULL, NULL,
- _gtk_marshal_VOID__OBJECT_OBJECT,
- G_TYPE_NONE, 2,
- GTK_TYPE_ACTION,
- GTK_TYPE_WIDGET);
-
- /**
- * GtkUIManager::pre-activate:
- * @manager: the ui manager
- * @action: the action
- *
- * The ::pre-activate signal is emitted just before the @action
- * is activated.
- *
- * This is intended for applications to get notification
- * just before any action is activated.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
- ui_manager_signals[PRE_ACTIVATE] =
- g_signal_new (I_("pre-activate"),
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
- G_STRUCT_OFFSET (GtkUIManagerClass, pre_activate),
- NULL, NULL,
- _gtk_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- GTK_TYPE_ACTION);
-
- /**
- * GtkUIManager::post-activate:
- * @manager: the ui manager
- * @action: the action
- *
- * The ::post-activate signal is emitted just after the @action
- * is activated.
- *
- * This is intended for applications to get notification
- * just after any action is activated.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- */
- ui_manager_signals[POST_ACTIVATE] =
- g_signal_new (I_("post-activate"),
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
- G_STRUCT_OFFSET (GtkUIManagerClass, post_activate),
- NULL, NULL,
- _gtk_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- GTK_TYPE_ACTION);
-
- klass->add_widget = NULL;
- klass->actions_changed = NULL;
- klass->connect_proxy = NULL;
- klass->disconnect_proxy = NULL;
- klass->pre_activate = NULL;
- klass->post_activate = NULL;
-}
-
-static void
-gtk_ui_manager_init (GtkUIManager *manager)
-{
- guint merge_id;
- GNode *node;
-
- manager->private_data = gtk_ui_manager_get_instance_private (manager);
-
- manager->private_data->accel_group = gtk_accel_group_new ();
-
- manager->private_data->root_node = NULL;
- manager->private_data->action_groups = NULL;
-
- manager->private_data->last_merge_id = 0;
- manager->private_data->add_tearoffs = FALSE;
-
- merge_id = gtk_ui_manager_new_merge_id (manager);
- node = get_child_node (manager, NULL, NULL, "ui", 2,
- NODE_TYPE_ROOT, TRUE, FALSE);
- node_prepend_ui_reference (node, merge_id, 0);
-}
-
-static void
-gtk_ui_manager_finalize (GObject *object)
-{
- GtkUIManager *manager = GTK_UI_MANAGER (object);
-
- if (manager->private_data->update_tag != 0)
- {
- g_source_remove (manager->private_data->update_tag);
- manager->private_data->update_tag = 0;
- }
-
- g_node_traverse (manager->private_data->root_node,
- G_POST_ORDER, G_TRAVERSE_ALL, -1,
- (GNodeTraverseFunc)free_node, NULL);
- g_node_destroy (manager->private_data->root_node);
- manager->private_data->root_node = NULL;
-
- g_list_free_full (manager->private_data->action_groups, g_object_unref);
- manager->private_data->action_groups = NULL;
-
- g_object_unref (manager->private_data->accel_group);
- manager->private_data->accel_group = NULL;
-
- G_OBJECT_CLASS (gtk_ui_manager_parent_class)->finalize (object);
-}
-
-static void
-gtk_ui_manager_buildable_init (GtkBuildableIface *iface)
-{
- iface->add_child = gtk_ui_manager_buildable_add_child;
- iface->construct_child = gtk_ui_manager_buildable_construct_child;
- iface->custom_tag_start = gtk_ui_manager_buildable_custom_tag_start;
- iface->custom_tag_end = gtk_ui_manager_buildable_custom_tag_end;
-}
-
-static void
-gtk_ui_manager_buildable_add_child (GtkBuildable *buildable,
- GtkBuilder *builder,
- GObject *child,
- const gchar *type)
-{
- GtkUIManager *manager = GTK_UI_MANAGER (buildable);
- guint pos;
-
- g_return_if_fail (GTK_IS_ACTION_GROUP (child));
-
- pos = g_list_length (manager->private_data->action_groups);
-
- gtk_ui_manager_insert_action_group (manager,
- GTK_ACTION_GROUP (child),
- pos);
-}
-
-static void
-child_hierarchy_changed_cb (GtkWidget *widget,
- GtkWidget *unused,
- GtkUIManager *uimgr)
-{
- GtkWidget *toplevel;
- GtkAccelGroup *group;
- GSList *groups;
-
- toplevel = gtk_widget_get_toplevel (widget);
- if (!toplevel || !GTK_IS_WINDOW (toplevel))
- return;
-
- group = gtk_ui_manager_get_accel_group (uimgr);
- groups = gtk_accel_groups_from_object (G_OBJECT (toplevel));
- if (g_slist_find (groups, group) == NULL)
- gtk_window_add_accel_group (GTK_WINDOW (toplevel), group);
-
- g_signal_handlers_disconnect_by_func (widget,
- child_hierarchy_changed_cb,
- uimgr);
-}
-
-static GObject *
-gtk_ui_manager_buildable_construct_child (GtkBuildable *buildable,
- GtkBuilder *builder,
- const gchar *id)
-{
- GtkWidget *widget;
- char *name;
-
- name = g_strdup_printf ("ui/%s", id);
- widget = gtk_ui_manager_get_widget (GTK_UI_MANAGER (buildable), name);
- if (!widget)
- {
- g_error ("Unknown ui manager child: %s\n", name);
- g_free (name);
- return NULL;
- }
- g_free (name);
-
- g_signal_connect (widget, "hierarchy-changed",
- G_CALLBACK (child_hierarchy_changed_cb),
- GTK_UI_MANAGER (buildable));
- return g_object_ref (widget);
-}
-
-static void
-gtk_ui_manager_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GtkUIManager *manager = GTK_UI_MANAGER (object);
-
- switch (prop_id)
- {
- case PROP_ADD_TEAROFFS:
- gtk_ui_manager_do_set_add_tearoffs (manager, g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gtk_ui_manager_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GtkUIManager *manager = GTK_UI_MANAGER (object);
-
- switch (prop_id)
- {
- case PROP_ADD_TEAROFFS:
- g_value_set_boolean (value, manager->private_data->add_tearoffs);
- break;
- case PROP_UI:
- g_value_take_string (value, gtk_ui_manager_get_ui (manager));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static GtkWidget *
-gtk_ui_manager_real_get_widget (GtkUIManager *manager,
- const gchar *path)
-{
- GNode *node;
-
- /* ensure that there are no pending updates before we get the
- * widget */
- gtk_ui_manager_ensure_update (manager);
-
- node = get_node (manager, path, NODE_TYPE_UNDECIDED, FALSE);
-
- if (node == NULL)
- return NULL;
-
- return NODE_INFO (node)->proxy;
-}
-
-static GtkAction *
-gtk_ui_manager_real_get_action (GtkUIManager *manager,
- const gchar *path)
-{
- GNode *node;
-
- /* ensure that there are no pending updates before we get
- * the action */
- gtk_ui_manager_ensure_update (manager);
-
- node = get_node (manager, path, NODE_TYPE_UNDECIDED, FALSE);
-
- if (node == NULL)
- return NULL;
-
- return NODE_INFO (node)->action;
-}
-
-
-/**
- * gtk_ui_manager_new:
- *
- * Creates a new ui manager object.
- *
- * Return value: a new ui manager object.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-GtkUIManager*
-gtk_ui_manager_new (void)
-{
- return g_object_new (GTK_TYPE_UI_MANAGER, NULL);
-}
-
-
-/**
- * gtk_ui_manager_get_add_tearoffs:
- * @manager: a #GtkUIManager
- *
- * Returns whether menus generated by this #GtkUIManager
- * will have tearoff menu items.
- *
- * Return value: whether tearoff menu items are added
- *
- * Since: 2.4
- *
- * Deprecated: 3.4: Tearoff menus are deprecated and should not
- * be used in newly written code.
- **/
-gboolean
-gtk_ui_manager_get_add_tearoffs (GtkUIManager *manager)
-{
- g_return_val_if_fail (GTK_IS_UI_MANAGER (manager), FALSE);
-
- return manager->private_data->add_tearoffs;
-}
-
-
-/**
- * gtk_ui_manager_set_add_tearoffs:
- * @manager: a #GtkUIManager
- * @add_tearoffs: whether tearoff menu items are added
- *
- * Sets the "add_tearoffs" property, which controls whether menus
- * generated by this #GtkUIManager will have tearoff menu items.
- *
- * Note that this only affects regular menus. Generated popup
- * menus never have tearoff menu items.
- *
- * Since: 2.4
- *
- * Deprecated: 3.4: Tearoff menus are deprecated and should not
- * be used in newly written code.
- **/
-void
-gtk_ui_manager_set_add_tearoffs (GtkUIManager *manager,
- gboolean add_tearoffs)
-{
- g_return_if_fail (GTK_IS_UI_MANAGER (manager));
-
- gtk_ui_manager_do_set_add_tearoffs (manager, add_tearoffs);
-}
-
-static void
-gtk_ui_manager_do_set_add_tearoffs (GtkUIManager *manager,
- gboolean add_tearoffs)
-{
- add_tearoffs = add_tearoffs != FALSE;
-
- if (add_tearoffs != manager->private_data->add_tearoffs)
- {
- manager->private_data->add_tearoffs = add_tearoffs;
-
- dirty_all_nodes (manager);
-
- g_object_notify (G_OBJECT (manager), "add-tearoffs");
- }
-}
-
-static void
-cb_proxy_connect_proxy (GtkActionGroup *group,
- GtkAction *action,
- GtkWidget *proxy,
- GtkUIManager *manager)
-{
- g_signal_emit (manager, ui_manager_signals[CONNECT_PROXY], 0, action, proxy);
-}
-
-static void
-cb_proxy_disconnect_proxy (GtkActionGroup *group,
- GtkAction *action,
- GtkWidget *proxy,
- GtkUIManager *manager)
-{
- g_signal_emit (manager, ui_manager_signals[DISCONNECT_PROXY], 0, action, proxy);
-}
-
-static void
-cb_proxy_pre_activate (GtkActionGroup *group,
- GtkAction *action,
- GtkUIManager *manager)
-{
- g_signal_emit (manager, ui_manager_signals[PRE_ACTIVATE], 0, action);
-}
-
-static void
-cb_proxy_post_activate (GtkActionGroup *group,
- GtkAction *action,
- GtkUIManager *manager)
-{
- g_signal_emit (manager, ui_manager_signals[POST_ACTIVATE], 0, action);
-}
-
-/**
- * gtk_ui_manager_insert_action_group:
- * @manager: a #GtkUIManager object
- * @action_group: the action group to be inserted
- * @pos: the position at which the group will be inserted.
- *
- * Inserts an action group into the list of action groups associated
- * with @manager. Actions in earlier groups hide actions with the same
- * name in later groups.
- *
- * If @pos is larger than the number of action groups in @manager, or
- * negative, @action_group will be inserted at the end of the internal
- * list.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-void
-gtk_ui_manager_insert_action_group (GtkUIManager *manager,
- GtkActionGroup *action_group,
- gint pos)
-{
-#ifdef G_ENABLE_DEBUG
- GList *l;
- const char *group_name;
-#endif
-
- g_return_if_fail (GTK_IS_UI_MANAGER (manager));
- g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
- g_return_if_fail (g_list_find (manager->private_data->action_groups,
- action_group) == NULL);
-
-#ifdef G_ENABLE_DEBUG
- group_name = gtk_action_group_get_name (action_group);
-
- for (l = manager->private_data->action_groups; l; l = l->next)
- {
- GtkActionGroup *group = l->data;
-
- if (strcmp (gtk_action_group_get_name (group), group_name) == 0)
- {
- g_warning ("Inserting action group '%s' into UI manager which "
- "already has a group with this name\n", group_name);
- break;
- }
- }
-#endif /* G_ENABLE_DEBUG */
-
- g_object_ref (action_group);
- manager->private_data->action_groups =
- g_list_insert (manager->private_data->action_groups, action_group, pos);
- g_object_connect (action_group,
- "object-signal::connect-proxy", G_CALLBACK (cb_proxy_connect_proxy), manager,
- "object-signal::disconnect-proxy", G_CALLBACK (cb_proxy_disconnect_proxy), manager,
- "object-signal::pre-activate", G_CALLBACK (cb_proxy_pre_activate), manager,
- "object-signal::post-activate", G_CALLBACK (cb_proxy_post_activate), manager,
- NULL);
-
- /* dirty all nodes, as action bindings may change */
- dirty_all_nodes (manager);
-
- g_signal_emit (manager, ui_manager_signals[ACTIONS_CHANGED], 0);
-}
-
-/**
- * gtk_ui_manager_remove_action_group:
- * @manager: a #GtkUIManager object
- * @action_group: the action group to be removed
- *
- * Removes an action group from the list of action groups associated
- * with @manager.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-void
-gtk_ui_manager_remove_action_group (GtkUIManager *manager,
- GtkActionGroup *action_group)
-{
- g_return_if_fail (GTK_IS_UI_MANAGER (manager));
- g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
- g_return_if_fail (g_list_find (manager->private_data->action_groups,
- action_group) != NULL);
-
- manager->private_data->action_groups =
- g_list_remove (manager->private_data->action_groups, action_group);
-
- g_object_disconnect (action_group,
- "any-signal::connect-proxy", G_CALLBACK (cb_proxy_connect_proxy), manager,
- "any-signal::disconnect-proxy", G_CALLBACK (cb_proxy_disconnect_proxy), manager,
- "any-signal::pre-activate", G_CALLBACK (cb_proxy_pre_activate), manager,
- "any-signal::post-activate", G_CALLBACK (cb_proxy_post_activate), manager,
- NULL);
- g_object_unref (action_group);
-
- /* dirty all nodes, as action bindings may change */
- dirty_all_nodes (manager);
-
- g_signal_emit (manager, ui_manager_signals[ACTIONS_CHANGED], 0);
-}
-
-/**
- * gtk_ui_manager_get_action_groups:
- * @manager: a #GtkUIManager object
- *
- * Returns the list of action groups associated with @manager.
- *
- * Return value: (element-type GtkActionGroup) (transfer none): a #GList of
- * action groups. The list is owned by GTK+
- * and should not be modified.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-GList *
-gtk_ui_manager_get_action_groups (GtkUIManager *manager)
-{
- g_return_val_if_fail (GTK_IS_UI_MANAGER (manager), NULL);
-
- return manager->private_data->action_groups;
-}
-
-/**
- * gtk_ui_manager_get_accel_group:
- * @manager: a #GtkUIManager object
- *
- * Returns the #GtkAccelGroup associated with @manager.
- *
- * Return value: (transfer none): the #GtkAccelGroup.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-GtkAccelGroup *
-gtk_ui_manager_get_accel_group (GtkUIManager *manager)
-{
- g_return_val_if_fail (GTK_IS_UI_MANAGER (manager), NULL);
-
- return manager->private_data->accel_group;
-}
-
-/**
- * gtk_ui_manager_get_widget:
- * @manager: a #GtkUIManager
- * @path: a path
- *
- * Looks up a widget by following a path.
- * The path consists of the names specified in the XML description of the UI.
- * separated by '/'. Elements which don't have a name or action attribute in
- * the XML (e.g. <popup>) can be addressed by their XML element name
- * (e.g. "popup"). The root element ("/ui") can be omitted in the path.
- *
- * Note that the widget found by following a path that ends in a <menu>
- * element is the menuitem to which the menu is attached, not the menu itmanager.
- *
- * Also note that the widgets constructed by a ui manager are not tied to
- * the lifecycle of the ui manager. If you add the widgets returned by this
- * function to some container or explicitly ref them, they will survive the
- * destruction of the ui manager.
- *
- * Return value: (transfer none): the widget found by following the path, or %NULL if no widget
- * was found.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-GtkWidget *
-gtk_ui_manager_get_widget (GtkUIManager *manager,
- const gchar *path)
-{
- g_return_val_if_fail (GTK_IS_UI_MANAGER (manager), NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- return GTK_UI_MANAGER_GET_CLASS (manager)->get_widget (manager, path);
-}
-
-typedef struct {
- GtkUIManagerItemType types;
- GSList *list;
-} ToplevelData;
-
-static void
-collect_toplevels (GNode *node,
- gpointer user_data)
-{
- ToplevelData *data = user_data;
-
- if (NODE_INFO (node)->proxy)
- {
- switch (NODE_INFO (node)->type)
- {
- case NODE_TYPE_MENUBAR:
- if (data->types & GTK_UI_MANAGER_MENUBAR)
- data->list = g_slist_prepend (data->list, NODE_INFO (node)->proxy);
- break;
- case NODE_TYPE_TOOLBAR:
- if (data->types & GTK_UI_MANAGER_TOOLBAR)
- data->list = g_slist_prepend (data->list, NODE_INFO (node)->proxy);
- break;
- case NODE_TYPE_POPUP:
- if (data->types & GTK_UI_MANAGER_POPUP)
- data->list = g_slist_prepend (data->list, NODE_INFO (node)->proxy);
- break;
- default: ;
- }
- }
-}
-
-/**
- * gtk_ui_manager_get_toplevels:
- * @manager: a #GtkUIManager
- * @types: specifies the types of toplevel widgets to include. Allowed
- * types are #GTK_UI_MANAGER_MENUBAR, #GTK_UI_MANAGER_TOOLBAR and
- * #GTK_UI_MANAGER_POPUP.
- *
- * Obtains a list of all toplevel widgets of the requested types.
- *
- * Return value: (element-type GtkWidget) (transfer container): a newly-allocated #GSList of
- * all toplevel widgets of the requested types. Free the returned list with g_slist_free().
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-GSList *
-gtk_ui_manager_get_toplevels (GtkUIManager *manager,
- GtkUIManagerItemType types)
-{
- ToplevelData data;
-
- g_return_val_if_fail (GTK_IS_UI_MANAGER (manager), NULL);
- g_return_val_if_fail ((~(GTK_UI_MANAGER_MENUBAR |
- GTK_UI_MANAGER_TOOLBAR |
- GTK_UI_MANAGER_POPUP) & types) == 0, NULL);
-
-
- data.types = types;
- data.list = NULL;
-
- g_node_children_foreach (manager->private_data->root_node,
- G_TRAVERSE_ALL,
- collect_toplevels, &data);
-
- return data.list;
-}
-
-
-/**
- * gtk_ui_manager_get_action:
- * @manager: a #GtkUIManager
- * @path: a path
- *
- * Looks up an action by following a path. See gtk_ui_manager_get_widget()
- * for more information about paths.
- *
- * Return value: (transfer none): the action whose proxy widget is found by following the path,
- * or %NULL if no widget was found.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-GtkAction *
-gtk_ui_manager_get_action (GtkUIManager *manager,
- const gchar *path)
-{
- g_return_val_if_fail (GTK_IS_UI_MANAGER (manager), NULL);
- g_return_val_if_fail (path != NULL, NULL);
-
- return GTK_UI_MANAGER_GET_CLASS (manager)->get_action (manager, path);
-}
-
-static gboolean
-node_is_dead (GNode *node)
-{
- GNode *child;
-
- if (NODE_INFO (node)->uifiles != NULL)
- return FALSE;
-
- for (child = node->children; child != NULL; child = child->next)
- {
- if (!node_is_dead (child))
- return FALSE;
- }
-
- return TRUE;
-}
-
-static GNode *
-get_child_node (GtkUIManager *manager,
- GNode *parent,
- GNode *sibling,
- const gchar *childname,
- gint childname_length,
- NodeType node_type,
- gboolean create,
- gboolean top)
-{
- GNode *child = NULL;
-
- if (parent)
- {
- if (childname)
- {
- for (child = parent->children; child != NULL; child = child->next)
- {
- if (NODE_INFO (child)->name &&
- strlen (NODE_INFO (child)->name) == childname_length &&
- !strncmp (NODE_INFO (child)->name, childname, childname_length))
- {
- /* if undecided about node type, set it */
- if (NODE_INFO (child)->type == NODE_TYPE_UNDECIDED)
- NODE_INFO (child)->type = node_type;
-
- /* warn about type mismatch */
- if (NODE_INFO (child)->type != NODE_TYPE_UNDECIDED &&
- node_type != NODE_TYPE_UNDECIDED &&
- NODE_INFO (child)->type != node_type)
- g_warning ("node type doesn't match %d (%s is type %d)",
- node_type,
- NODE_INFO (child)->name,
- NODE_INFO (child)->type);
-
- if (node_is_dead (child))
- {
- /* This node was removed but is still dirty so
- * it is still in the tree. We want to treat this
- * as if it didn't exist, which means we move it
- * to the position it would have been created at.
- */
- g_node_unlink (child);
- goto insert_child;
- }
-
- return child;
- }
- }
- }
- if (!child && create)
- {
- Node *mnode;
-
- mnode = g_slice_new0 (Node);
- mnode->type = node_type;
- mnode->name = g_strndup (childname, childname_length);
-
- child = g_node_new (mnode);
- insert_child:
- if (sibling)
- {
- if (top)
- g_node_insert_before (parent, sibling, child);
- else
- g_node_insert_after (parent, sibling, child);
- }
- else
- {
- if (top)
- g_node_prepend (parent, child);
- else
- g_node_append (parent, child);
- }
-
- mark_node_dirty (child);
- }
- }
- else
- {
- /* handle root node */
- if (manager->private_data->root_node)
- {
- child = manager->private_data->root_node;
- if (strncmp (NODE_INFO (child)->name, childname, childname_length) != 0)
- g_warning ("root node name '%s' doesn't match '%s'",
- childname, NODE_INFO (child)->name);
- if (NODE_INFO (child)->type != NODE_TYPE_ROOT)
- g_warning ("base element must be of type ROOT");
- }
- else if (create)
- {
- Node *mnode;
-
- mnode = g_slice_new0 (Node);
- mnode->type = node_type;
- mnode->name = g_strndup (childname, childname_length);
- mnode->dirty = TRUE;
-
- child = manager->private_data->root_node = g_node_new (mnode);
- }
- }
-
- return child;
-}
-
-static GNode *
-get_node (GtkUIManager *manager,
- const gchar *path,
- NodeType node_type,
- gboolean create)
-{
- const gchar *pos, *end;
- GNode *parent, *node;
-
- if (strncmp ("/ui", path, 3) == 0)
- path += 3;
-
- end = path + strlen (path);
- pos = path;
- parent = node = NULL;
- while (pos < end)
- {
- const gchar *slash;
- gsize length;
-
- slash = strchr (pos, '/');
- if (slash)
- length = slash - pos;
- else
- length = strlen (pos);
-
- node = get_child_node (manager, parent, NULL, pos, length, NODE_TYPE_UNDECIDED,
- create, FALSE);
- if (!node)
- return NULL;
-
- pos += length + 1; /* move past the node name and the slash too */
- parent = node;
- }
-
- if (node != NULL && NODE_INFO (node)->type == NODE_TYPE_UNDECIDED)
- NODE_INFO (node)->type = node_type;
-
- return node;
-}
-
-static void
-node_ui_reference_free (gpointer data)
-{
- g_slice_free (NodeUIReference, data);
-}
-
-static gboolean
-free_node (GNode *node)
-{
- Node *info = NODE_INFO (node);
-
- g_list_free_full (info->uifiles, node_ui_reference_free);
- info->uifiles = NULL;
-
- g_clear_object (&info->action);
- g_clear_object (&info->proxy);
- g_clear_object (&info->extra);
- g_clear_pointer (&info->name, g_free);
- g_slice_free (Node, info);
- node->data = NULL;
-
- return FALSE;
-}
-
-/**
- * gtk_ui_manager_new_merge_id:
- * @manager: a #GtkUIManager
- *
- * Returns an unused merge id, suitable for use with
- * gtk_ui_manager_add_ui().
- *
- * Return value: an unused merge id.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-guint
-gtk_ui_manager_new_merge_id (GtkUIManager *manager)
-{
- manager->private_data->last_merge_id++;
-
- return manager->private_data->last_merge_id;
-}
-
-static void
-node_prepend_ui_reference (GNode *gnode,
- guint merge_id,
- GQuark action_quark)
-{
- Node *node = NODE_INFO (gnode);
- NodeUIReference *reference = NULL;
-
- if (node->uifiles &&
- ((NodeUIReference *)node->uifiles->data)->merge_id == merge_id)
- reference = node->uifiles->data;
- else
- {
- reference = g_slice_new (NodeUIReference);
- node->uifiles = g_list_prepend (node->uifiles, reference);
- }
-
- reference->merge_id = merge_id;
- reference->action_quark = action_quark;
-
- mark_node_dirty (gnode);
-}
-
-static void
-node_remove_ui_reference (GNode *gnode,
- guint merge_id)
-{
- Node *node = NODE_INFO (gnode);
- GList *p;
-
- for (p = node->uifiles; p != NULL; p = p->next)
- {
- NodeUIReference *reference = p->data;
-
- if (reference->merge_id == merge_id)
- {
- if (p == node->uifiles)
- mark_node_dirty (gnode);
- node->uifiles = g_list_delete_link (node->uifiles, p);
- g_slice_free (NodeUIReference, reference);
-
- break;
- }
- }
-}
-
-/* -------------------- The UI file parser -------------------- */
-
-typedef enum
-{
- STATE_START,
- STATE_ROOT,
- STATE_MENU,
- STATE_TOOLBAR,
- STATE_MENUITEM,
- STATE_TOOLITEM,
- STATE_ACCELERATOR,
- STATE_END
-} ParseState;
-
-typedef struct _ParseContext ParseContext;
-struct _ParseContext
-{
- ParseState state;
- ParseState prev_state;
-
- GtkUIManager *manager;
-
- GNode *current;
-
- guint merge_id;
-};
-
-static void
-start_element_handler (GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- gpointer user_data,
- GError **error)
-{
- ParseContext *ctx = user_data;
- GtkUIManager *manager = ctx->manager;
-
- gint i;
- const gchar *node_name;
- const gchar *action;
- GQuark action_quark;
- gboolean top;
- gboolean expand = FALSE;
- gboolean accelerators = FALSE;
- gboolean always_show_image_set = FALSE, always_show_image = FALSE;
-
- gboolean raise_error = TRUE;
-
- node_name = NULL;
- action = NULL;
- action_quark = 0;
- top = FALSE;
-
- for (i = 0; attribute_names[i] != NULL; i++)
- {
- if (!strcmp (attribute_names[i], "name"))
- {
- node_name = attribute_values[i];
- }
- else if (!strcmp (attribute_names[i], "action"))
- {
- action = attribute_values[i];
- action_quark = g_quark_from_string (attribute_values[i]);
- }
- else if (!strcmp (attribute_names[i], "position"))
- {
- top = !strcmp (attribute_values[i], "top");
- }
- else if (!strcmp (attribute_names[i], "expand"))
- {
- expand = !strcmp (attribute_values[i], "true");
- }
- else if (!strcmp (attribute_names[i], "accelerators"))
- {
- accelerators = !strcmp (attribute_values[i], "true");
- }
- else if (!strcmp (attribute_names[i], "always-show-image"))
- {
- always_show_image_set = TRUE;
- always_show_image = !strcmp (attribute_values[i], "true");
- }
- /* else silently skip unknown attributes to be compatible with
- * future additional attributes.
- */
- }
-
- /* Work out a name for this node. Either the name attribute, or
- * the action, or the element name */
- if (node_name == NULL)
- {
- if (action != NULL)
- node_name = action;
- else
- node_name = element_name;
- }
-
- switch (element_name[0])
- {
- case 'a':
- if (ctx->state == STATE_ROOT && !strcmp (element_name, "accelerator"))
- {
- ctx->state = STATE_ACCELERATOR;
- ctx->current = get_child_node (manager, ctx->current, NULL,
- node_name, strlen (node_name),
- NODE_TYPE_ACCELERATOR,
- TRUE, FALSE);
- if (NODE_INFO (ctx->current)->action_name == 0)
- NODE_INFO (ctx->current)->action_name = action_quark;
-
- node_prepend_ui_reference (ctx->current, ctx->merge_id, action_quark);
-
- raise_error = FALSE;
- }
- break;
- case 'u':
- if (ctx->state == STATE_START && !strcmp (element_name, "ui"))
- {
- ctx->state = STATE_ROOT;
- ctx->current = manager->private_data->root_node;
- raise_error = FALSE;
-
- node_prepend_ui_reference (ctx->current, ctx->merge_id, action_quark);
- }
- break;
- case 'm':
- if (ctx->state == STATE_ROOT && !strcmp (element_name, "menubar"))
- {
- ctx->state = STATE_MENU;
- ctx->current = get_child_node (manager, ctx->current, NULL,
- node_name, strlen (node_name),
- NODE_TYPE_MENUBAR,
- TRUE, FALSE);
- if (NODE_INFO (ctx->current)->action_name == 0)
- NODE_INFO (ctx->current)->action_name = action_quark;
-
- node_prepend_ui_reference (ctx->current, ctx->merge_id, action_quark);
- mark_node_dirty (ctx->current);
-
- raise_error = FALSE;
- }
- else if (ctx->state == STATE_MENU && !strcmp (element_name, "menu"))
- {
- ctx->current = get_child_node (manager, ctx->current, NULL,
- node_name, strlen (node_name),
- NODE_TYPE_MENU,
- TRUE, top);
- if (NODE_INFO (ctx->current)->action_name == 0)
- NODE_INFO (ctx->current)->action_name = action_quark;
-
- node_prepend_ui_reference (ctx->current, ctx->merge_id, action_quark);
-
- raise_error = FALSE;
- }
- else if (ctx->state == STATE_TOOLITEM && !strcmp (element_name, "menu"))
- {
- ctx->state = STATE_MENU;
-
- ctx->current = get_child_node (manager, g_node_last_child (ctx->current), NULL,
- node_name, strlen (node_name),
- NODE_TYPE_MENU,
- TRUE, top);
- if (NODE_INFO (ctx->current)->action_name == 0)
- NODE_INFO (ctx->current)->action_name = action_quark;
-
- node_prepend_ui_reference (ctx->current, ctx->merge_id, action_quark);
-
- raise_error = FALSE;
- }
- else if (ctx->state == STATE_MENU && !strcmp (element_name, "menuitem"))
- {
- GNode *node;
-
- ctx->state = STATE_MENUITEM;
- node = get_child_node (manager, ctx->current, NULL,
- node_name, strlen (node_name),
- NODE_TYPE_MENUITEM,
- TRUE, top);
- if (NODE_INFO (node)->action_name == 0)
- NODE_INFO (node)->action_name = action_quark;
-
- NODE_INFO (node)->always_show_image_set = always_show_image_set;
- NODE_INFO (node)->always_show_image = always_show_image;
-
- node_prepend_ui_reference (node, ctx->merge_id, action_quark);
-
- raise_error = FALSE;
- }
- break;
- case 'p':
- if (ctx->state == STATE_ROOT && !strcmp (element_name, "popup"))
- {
- ctx->state = STATE_MENU;
- ctx->current = get_child_node (manager, ctx->current, NULL,
- node_name, strlen (node_name),
- NODE_TYPE_POPUP,
- TRUE, FALSE);
-
- NODE_INFO (ctx->current)->popup_accels = accelerators;
-
- if (NODE_INFO (ctx->current)->action_name == 0)
- NODE_INFO (ctx->current)->action_name = action_quark;
-
- node_prepend_ui_reference (ctx->current, ctx->merge_id, action_quark);
-
- raise_error = FALSE;
- }
- else if ((ctx->state == STATE_MENU || ctx->state == STATE_TOOLBAR) &&
- !strcmp (element_name, "placeholder"))
- {
- if (ctx->state == STATE_TOOLBAR)
- ctx->current = get_child_node (manager, ctx->current, NULL,
- node_name, strlen (node_name),
- NODE_TYPE_TOOLBAR_PLACEHOLDER,
- TRUE, top);
- else
- ctx->current = get_child_node (manager, ctx->current, NULL,
- node_name, strlen (node_name),
- NODE_TYPE_MENU_PLACEHOLDER,
- TRUE, top);
-
- node_prepend_ui_reference (ctx->current, ctx->merge_id, action_quark);
-
- raise_error = FALSE;
- }
- break;
- case 's':
- if ((ctx->state == STATE_MENU || ctx->state == STATE_TOOLBAR) &&
- !strcmp (element_name, "separator"))
- {
- GNode *node;
- gint length;
-
- if (ctx->state == STATE_TOOLBAR)
- ctx->state = STATE_TOOLITEM;
- else
- ctx->state = STATE_MENUITEM;
- if (!strcmp (node_name, "separator"))
- {
- node_name = NULL;
- length = 0;
- }
- else
- length = strlen (node_name);
- node = get_child_node (manager, ctx->current, NULL,
- node_name, length,
- NODE_TYPE_SEPARATOR,
- TRUE, top);
-
- NODE_INFO (node)->expand = expand;
-
- if (NODE_INFO (node)->action_name == 0)
- NODE_INFO (node)->action_name = action_quark;
-
- node_prepend_ui_reference (node, ctx->merge_id, action_quark);
-
- raise_error = FALSE;
- }
- break;
- case 't':
- if (ctx->state == STATE_ROOT && !strcmp (element_name, "toolbar"))
- {
- ctx->state = STATE_TOOLBAR;
- ctx->current = get_child_node (manager, ctx->current, NULL,
- node_name, strlen (node_name),
- NODE_TYPE_TOOLBAR,
- TRUE, FALSE);
- if (NODE_INFO (ctx->current)->action_name == 0)
- NODE_INFO (ctx->current)->action_name = action_quark;
-
- node_prepend_ui_reference (ctx->current, ctx->merge_id, action_quark);
-
- raise_error = FALSE;
- }
- else if (ctx->state == STATE_TOOLBAR && !strcmp (element_name, "toolitem"))
- {
- GNode *node;
-
- ctx->state = STATE_TOOLITEM;
- node = get_child_node (manager, ctx->current, NULL,
- node_name, strlen (node_name),
- NODE_TYPE_TOOLITEM,
- TRUE, top);
- if (NODE_INFO (node)->action_name == 0)
- NODE_INFO (node)->action_name = action_quark;
-
- node_prepend_ui_reference (node, ctx->merge_id, action_quark);
-
- raise_error = FALSE;
- }
- break;
- default:
- break;
- }
- if (raise_error)
- {
- gint line_number, char_number;
-
- g_markup_parse_context_get_position (context,
- &line_number, &char_number);
- g_set_error (error,
- G_MARKUP_ERROR,
- G_MARKUP_ERROR_UNKNOWN_ELEMENT,
- _("Unexpected start tag '%s' on line %d char %d"),
- element_name,
- line_number, char_number);
- }
-}
-
-static void
-end_element_handler (GMarkupParseContext *context,
- const gchar *element_name,
- gpointer user_data,
- GError **error)
-{
- ParseContext *ctx = user_data;
-
- switch (ctx->state)
- {
- case STATE_START:
- case STATE_END:
- /* no need to GError here, GMarkup already catches this */
- break;
- case STATE_ROOT:
- ctx->current = NULL;
- ctx->state = STATE_END;
- break;
- case STATE_MENU:
- case STATE_TOOLBAR:
- case STATE_ACCELERATOR:
- ctx->current = ctx->current->parent;
- if (NODE_INFO (ctx->current)->type == NODE_TYPE_ROOT)
- ctx->state = STATE_ROOT;
- else if (NODE_INFO (ctx->current)->type == NODE_TYPE_TOOLITEM)
- {
- ctx->current = ctx->current->parent;
- ctx->state = STATE_TOOLITEM;
- }
- /* else, stay in same state */
- break;
- case STATE_MENUITEM:
- ctx->state = STATE_MENU;
- break;
- case STATE_TOOLITEM:
- ctx->state = STATE_TOOLBAR;
- break;
- }
-}
-
-static void
-cleanup (GMarkupParseContext *context,
- GError *error,
- gpointer user_data)
-{
- ParseContext *ctx = user_data;
-
- ctx->current = NULL;
- /* should also walk through the tree and get rid of nodes related to
- * this UI file's tag */
-
- gtk_ui_manager_remove_ui (ctx->manager, ctx->merge_id);
-}
-
-static gboolean
-xml_isspace (char c)
-{
- return c == ' ' || c == '\t' || c == '\n' || c == '\r';
-}
-
-static void
-text_handler (GMarkupParseContext *context,
- const gchar *text,
- gsize text_len,
- gpointer user_data,
- GError **error)
-{
- const gchar *p;
- const gchar *end;
-
- p = text;
- end = text + text_len;
- while (p != end && xml_isspace (*p))
- ++p;
-
- if (p != end)
- {
- gint line_number, char_number;
-
- g_markup_parse_context_get_position (context,
- &line_number, &char_number);
- g_set_error (error,
- G_MARKUP_ERROR,
- G_MARKUP_ERROR_INVALID_CONTENT,
- _("Unexpected character data on line %d char %d"),
- line_number, char_number);
- }
-}
-
-
-static const GMarkupParser ui_parser = {
- start_element_handler,
- end_element_handler,
- text_handler,
- NULL,
- cleanup
-};
-
-static guint
-add_ui_from_string (GtkUIManager *manager,
- const gchar *buffer,
- gssize length,
- gboolean needs_root,
- GError **error)
-{
- ParseContext ctx = { 0 };
- GMarkupParseContext *context;
-
- ctx.state = STATE_START;
- ctx.manager = manager;
- ctx.current = NULL;
- ctx.merge_id = gtk_ui_manager_new_merge_id (manager);
-
- context = g_markup_parse_context_new (&ui_parser, 0, &ctx, NULL);
-
- if (needs_root)
- if (!g_markup_parse_context_parse (context, "<ui>", -1, error))
- goto out;
-
- if (!g_markup_parse_context_parse (context, buffer, length, error))
- goto out;
-
- if (needs_root)
- if (!g_markup_parse_context_parse (context, "</ui>", -1, error))
- goto out;
-
- if (!g_markup_parse_context_end_parse (context, error))
- goto out;
-
- g_markup_parse_context_free (context);
-
- queue_update (manager);
-
- g_object_notify (G_OBJECT (manager), "ui");
-
- return ctx.merge_id;
-
- out:
-
- g_markup_parse_context_free (context);
-
- return 0;
-}
-
-/**
- * gtk_ui_manager_add_ui_from_string:
- * @manager: a #GtkUIManager object
- * @buffer: the string to parse
- * @length: the length of @buffer (may be -1 if @buffer is nul-terminated)
- * @error: return location for an error
- *
- * Parses a string containing a <link linkend="XML-UI">UI definition</link> and
- * merges it with the current contents of @manager. An enclosing <ui>
- * element is added if it is missing.
- *
- * Return value: The merge id for the merged UI. The merge id can be used
- * to unmerge the UI with gtk_ui_manager_remove_ui(). If an error occurred,
- * the return value is 0.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-guint
-gtk_ui_manager_add_ui_from_string (GtkUIManager *manager,
- const gchar *buffer,
- gssize length,
- GError **error)
-{
- gboolean needs_root = TRUE;
- const gchar *p;
- const gchar *end;
-
- g_return_val_if_fail (GTK_IS_UI_MANAGER (manager), 0);
- g_return_val_if_fail (buffer != NULL, 0);
-
- if (length < 0)
- length = strlen (buffer);
-
- p = buffer;
- end = buffer + length;
- while (p != end && xml_isspace (*p))
- ++p;
-
- if (end - p >= 4 && strncmp (p, "<ui>", 4) == 0)
- needs_root = FALSE;
-
- return add_ui_from_string (manager, buffer, length, needs_root, error);
-}
-
-/**
- * gtk_ui_manager_add_ui_from_file:
- * @manager: a #GtkUIManager object
- * @filename: (type filename): the name of the file to parse
- * @error: return location for an error
- *
- * Parses a file containing a <link linkend="XML-UI">UI definition</link> and
- * merges it with the current contents of @manager.
- *
- * Return value: The merge id for the merged UI. The merge id can be used
- * to unmerge the UI with gtk_ui_manager_remove_ui(). If an error occurred,
- * the return value is 0.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-guint
-gtk_ui_manager_add_ui_from_file (GtkUIManager *manager,
- const gchar *filename,
- GError **error)
-{
- gchar *buffer;
- gsize length;
- guint res;
-
- g_return_val_if_fail (GTK_IS_UI_MANAGER (manager), 0);
-
- if (!g_file_get_contents (filename, &buffer, &length, error))
- return 0;
-
- res = add_ui_from_string (manager, buffer, length, FALSE, error);
- g_free (buffer);
-
- return res;
-}
-
-/**
- * gtk_ui_manager_add_ui_from_resource:
- * @manager: a #GtkUIManager object
- * @resource_path: the resource path of the file to parse
- * @error: return location for an error
- *
- * Parses a resource file containing a <link linkend="XML-UI">UI definition</link> and
- * merges it with the current contents of @manager.
- *
- * Return value: The merge id for the merged UI. The merge id can be used
- * to unmerge the UI with gtk_ui_manager_remove_ui(). If an error occurred,
- * the return value is 0.
- *
- * Since: 3.4
- *
- * Deprecated: 3.10
- **/
-guint
-gtk_ui_manager_add_ui_from_resource (GtkUIManager *manager,
- const gchar *resource_path,
- GError **error)
-{
- GBytes *data;
- guint res;
-
- g_return_val_if_fail (GTK_IS_UI_MANAGER (manager), 0);
-
- data = g_resources_lookup_data (resource_path, 0, error);
- if (data == NULL)
- return 0;
-
- res = add_ui_from_string (manager, g_bytes_get_data (data, NULL), g_bytes_get_size (data), FALSE, error);
- g_bytes_unref (data);
-
- return res;
-}
-
-/**
- * gtk_ui_manager_add_ui:
- * @manager: a #GtkUIManager
- * @merge_id: the merge id for the merged UI, see gtk_ui_manager_new_merge_id()
- * @path: a path
- * @name: the name for the added UI element
- * @action: (allow-none): the name of the action to be proxied, or %NULL to add a separator
- * @type: the type of UI element to add.
- * @top: if %TRUE, the UI element is added before its siblings, otherwise it
- * is added after its siblings.
- *
- * Adds a UI element to the current contents of @manager.
- *
- * If @type is %GTK_UI_MANAGER_AUTO, GTK+ inserts a menuitem, toolitem or
- * separator if such an element can be inserted at the place determined by
- * @path. Otherwise @type must indicate an element that can be inserted at
- * the place determined by @path.
- *
- * If @path points to a menuitem or toolitem, the new element will be inserted
- * before or after this item, depending on @top.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-void
-gtk_ui_manager_add_ui (GtkUIManager *manager,
- guint merge_id,
- const gchar *path,
- const gchar *name,
- const gchar *action,
- GtkUIManagerItemType type,
- gboolean top)
-{
- GNode *node;
- GNode *sibling;
- GNode *child;
- NodeType node_type;
- GQuark action_quark = 0;
-
- g_return_if_fail (GTK_IS_UI_MANAGER (manager));
- g_return_if_fail (merge_id > 0);
- g_return_if_fail (name != NULL || type == GTK_UI_MANAGER_SEPARATOR);
-
- node = get_node (manager, path, NODE_TYPE_UNDECIDED, FALSE);
- sibling = NULL;
-
- if (node == NULL)
- return;
-
- node_type = NODE_TYPE_UNDECIDED;
-
- reswitch:
- switch (NODE_INFO (node)->type)
- {
- case NODE_TYPE_SEPARATOR:
- case NODE_TYPE_MENUITEM:
- case NODE_TYPE_TOOLITEM:
- sibling = node;
- node = node->parent;
- goto reswitch;
- case NODE_TYPE_MENUBAR:
- case NODE_TYPE_MENU:
- case NODE_TYPE_POPUP:
- case NODE_TYPE_MENU_PLACEHOLDER:
- switch (type)
- {
- case GTK_UI_MANAGER_AUTO:
- if (action != NULL)
- node_type = NODE_TYPE_MENUITEM;
- else
- node_type = NODE_TYPE_SEPARATOR;
- break;
- case GTK_UI_MANAGER_MENU:
- node_type = NODE_TYPE_MENU;
- break;
- case GTK_UI_MANAGER_MENUITEM:
- node_type = NODE_TYPE_MENUITEM;
- break;
- case GTK_UI_MANAGER_SEPARATOR:
- node_type = NODE_TYPE_SEPARATOR;
- break;
- case GTK_UI_MANAGER_PLACEHOLDER:
- node_type = NODE_TYPE_MENU_PLACEHOLDER;
- break;
- default: ;
- /* do nothing */
- }
- break;
- case NODE_TYPE_TOOLBAR:
- case NODE_TYPE_TOOLBAR_PLACEHOLDER:
- switch (type)
- {
- case GTK_UI_MANAGER_AUTO:
- if (action != NULL)
- node_type = NODE_TYPE_TOOLITEM;
- else
- node_type = NODE_TYPE_SEPARATOR;
- break;
- case GTK_UI_MANAGER_TOOLITEM:
- node_type = NODE_TYPE_TOOLITEM;
- break;
- case GTK_UI_MANAGER_SEPARATOR:
- node_type = NODE_TYPE_SEPARATOR;
- break;
- case GTK_UI_MANAGER_PLACEHOLDER:
- node_type = NODE_TYPE_TOOLBAR_PLACEHOLDER;
- break;
- default: ;
- /* do nothing */
- }
- break;
- case NODE_TYPE_ROOT:
- switch (type)
- {
- case GTK_UI_MANAGER_MENUBAR:
- node_type = NODE_TYPE_MENUBAR;
- break;
- case GTK_UI_MANAGER_TOOLBAR:
- node_type = NODE_TYPE_TOOLBAR;
- break;
- case GTK_UI_MANAGER_POPUP:
- case GTK_UI_MANAGER_POPUP_WITH_ACCELS:
- node_type = NODE_TYPE_POPUP;
- break;
- case GTK_UI_MANAGER_ACCELERATOR:
- node_type = NODE_TYPE_ACCELERATOR;
- break;
- default: ;
- /* do nothing */
- }
- break;
- default: ;
- /* do nothing */
- }
-
- if (node_type == NODE_TYPE_UNDECIDED)
- {
- g_warning ("item type %d not suitable for adding at '%s'",
- type, path);
- return;
- }
-
- child = get_child_node (manager, node, sibling,
- name, name ? strlen (name) : 0,
- node_type, TRUE, top);
-
- if (type == GTK_UI_MANAGER_POPUP_WITH_ACCELS)
- NODE_INFO (child)->popup_accels = TRUE;
-
- if (action != NULL)
- action_quark = g_quark_from_string (action);
-
- node_prepend_ui_reference (child, merge_id, action_quark);
-
- if (NODE_INFO (child)->action_name == 0)
- NODE_INFO (child)->action_name = action_quark;
-
- queue_update (manager);
-
- g_object_notify (G_OBJECT (manager), "ui");
-}
-
-static gboolean
-remove_ui (GNode *node,
- gpointer user_data)
-{
- guint merge_id = GPOINTER_TO_UINT (user_data);
-
- node_remove_ui_reference (node, merge_id);
-
- return FALSE; /* continue */
-}
-
-/**
- * gtk_ui_manager_remove_ui:
- * @manager: a #GtkUIManager object
- * @merge_id: a merge id as returned by gtk_ui_manager_add_ui_from_string()
- *
- * Unmerges the part of @manager<!-- -->s content identified by @merge_id.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-void
-gtk_ui_manager_remove_ui (GtkUIManager *manager,
- guint merge_id)
-{
- g_return_if_fail (GTK_IS_UI_MANAGER (manager));
-
- g_node_traverse (manager->private_data->root_node,
- G_POST_ORDER, G_TRAVERSE_ALL, -1,
- remove_ui, GUINT_TO_POINTER (merge_id));
-
- queue_update (manager);
-
- g_object_notify (G_OBJECT (manager), "ui");
-}
-
-/* -------------------- Updates -------------------- */
-
-
-static GtkAction *
-get_action_by_name (GtkUIManager *merge,
- const gchar *action_name)
-{
- GList *tmp;
-
- if (!action_name)
- return NULL;
-
- /* lookup name */
- for (tmp = merge->private_data->action_groups; tmp != NULL; tmp = tmp->next)
- {
- GtkActionGroup *action_group = tmp->data;
- GtkAction *action;
-
- action = gtk_action_group_get_action (action_group, action_name);
-
- if (action)
- return action;
- }
-
- return NULL;
-}
-
-static gboolean
-find_menu_position (GNode *node,
- GtkWidget **menushell_p,
- gint *pos_p)
-{
- GtkWidget *menushell;
- gint pos = 0;
-
- g_return_val_if_fail (node != NULL, FALSE);
- g_return_val_if_fail (NODE_INFO (node)->type == NODE_TYPE_MENU ||
- NODE_INFO (node)->type == NODE_TYPE_POPUP ||
- NODE_INFO (node)->type == NODE_TYPE_MENU_PLACEHOLDER ||
- NODE_INFO (node)->type == NODE_TYPE_MENUITEM ||
- NODE_INFO (node)->type == NODE_TYPE_SEPARATOR,
- FALSE);
-
- /* first sibling -- look at parent */
- if (node->prev == NULL)
- {
- GNode *parent;
- GList *siblings;
-
- parent = node->parent;
- switch (NODE_INFO (parent)->type)
- {
- case NODE_TYPE_MENUBAR:
- case NODE_TYPE_POPUP:
- menushell = NODE_INFO (parent)->proxy;
- pos = 0;
- break;
- case NODE_TYPE_MENU:
- menushell = NODE_INFO (parent)->proxy;
- if (GTK_IS_MENU_ITEM (menushell))
- menushell = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menushell));
- siblings = gtk_container_get_children (GTK_CONTAINER (menushell));
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-
- if (siblings != NULL && GTK_IS_TEAROFF_MENU_ITEM (siblings->data))
- pos = 1;
- else
- pos = 0;
-
-G_GNUC_END_IGNORE_DEPRECATIONS
-
- g_list_free (siblings);
- break;
- case NODE_TYPE_MENU_PLACEHOLDER:
- menushell = gtk_widget_get_parent (NODE_INFO (parent)->proxy);
- g_return_val_if_fail (GTK_IS_MENU_SHELL (menushell), FALSE);
- pos = g_list_index (GTK_MENU_SHELL (menushell)->priv->children,
- NODE_INFO (parent)->proxy) + 1;
- break;
- default:
- g_warning ("%s: bad parent node type %d", G_STRLOC,
- NODE_INFO (parent)->type);
- return FALSE;
- }
- }
- else
- {
- GtkWidget *prev_child;
- GNode *sibling;
-
- sibling = node->prev;
- if (NODE_INFO (sibling)->type == NODE_TYPE_MENU_PLACEHOLDER)
- prev_child = NODE_INFO (sibling)->extra; /* second Separator */
- else
- prev_child = NODE_INFO (sibling)->proxy;
-
- if (!GTK_IS_WIDGET (prev_child))
- return FALSE;
-
- menushell = gtk_widget_get_parent (prev_child);
- if (!GTK_IS_MENU_SHELL (menushell))
- return FALSE;
-
- pos = g_list_index (GTK_MENU_SHELL (menushell)->priv->children, prev_child) + 1;
- }
-
- if (menushell_p)
- *menushell_p = menushell;
- if (pos_p)
- *pos_p = pos;
-
- return TRUE;
-}
-
-static gboolean
-find_toolbar_position (GNode *node,
- GtkWidget **toolbar_p,
- gint *pos_p)
-{
- GtkWidget *toolbar;
- gint pos;
-
- g_return_val_if_fail (node != NULL, FALSE);
- g_return_val_if_fail (NODE_INFO (node)->type == NODE_TYPE_TOOLBAR ||
- NODE_INFO (node)->type == NODE_TYPE_TOOLBAR_PLACEHOLDER ||
- NODE_INFO (node)->type == NODE_TYPE_TOOLITEM ||
- NODE_INFO (node)->type == NODE_TYPE_SEPARATOR,
- FALSE);
-
- /* first sibling -- look at parent */
- if (node->prev == NULL)
- {
- GNode *parent;
-
- parent = node->parent;
- switch (NODE_INFO (parent)->type)
- {
- case NODE_TYPE_TOOLBAR:
- toolbar = NODE_INFO (parent)->proxy;
- pos = 0;
- break;
- case NODE_TYPE_TOOLBAR_PLACEHOLDER:
- toolbar = gtk_widget_get_parent (NODE_INFO (parent)->proxy);
- g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), FALSE);
- pos = gtk_toolbar_get_item_index (GTK_TOOLBAR (toolbar),
- GTK_TOOL_ITEM (NODE_INFO (parent)->proxy)) + 1;
- break;
- default:
- g_warning ("%s: bad parent node type %d", G_STRLOC,
- NODE_INFO (parent)->type);
- return FALSE;
- }
- }
- else
- {
- GtkWidget *prev_child;
- GNode *sibling;
-
- sibling = node->prev;
- if (NODE_INFO (sibling)->type == NODE_TYPE_TOOLBAR_PLACEHOLDER)
- prev_child = NODE_INFO (sibling)->extra; /* second Separator */
- else
- prev_child = NODE_INFO (sibling)->proxy;
-
- if (!GTK_IS_WIDGET (prev_child))
- return FALSE;
-
- toolbar = gtk_widget_get_parent (prev_child);
- if (!GTK_IS_TOOLBAR (toolbar))
- return FALSE;
-
- pos = gtk_toolbar_get_item_index (GTK_TOOLBAR (toolbar),
- GTK_TOOL_ITEM (prev_child)) + 1;
- }
-
- if (toolbar_p)
- *toolbar_p = toolbar;
- if (pos_p)
- *pos_p = pos;
-
- return TRUE;
-}
-
-enum {
- SEPARATOR_MODE_SMART,
- SEPARATOR_MODE_VISIBLE,
- SEPARATOR_MODE_HIDDEN
-};
-
-static void
-update_smart_separators (GtkWidget *proxy)
-{
- GtkWidget *parent = NULL;
-
- if (GTK_IS_MENU (proxy) || GTK_IS_TOOLBAR (proxy))
- parent = proxy;
- else if (GTK_IS_MENU_ITEM (proxy) || GTK_IS_TOOL_ITEM (proxy))
- parent = gtk_widget_get_parent (proxy);
-
- if (parent)
- {
- gboolean visible;
- gboolean empty;
- GList *children, *cur, *last;
- GtkWidget *filler;
-
- children = gtk_container_get_children (GTK_CONTAINER (parent));
-
- visible = FALSE;
- last = NULL;
- empty = TRUE;
- filler = NULL;
-
- cur = children;
- while (cur)
- {
- if (g_object_get_data (cur->data, "gtk-empty-menu-item"))
- {
- filler = cur->data;
- }
- else if (GTK_IS_SEPARATOR_MENU_ITEM (cur->data) ||
- GTK_IS_SEPARATOR_TOOL_ITEM (cur->data))
- {
- gint mode =
- GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cur->data),
- "gtk-separator-mode"));
- switch (mode)
- {
- case SEPARATOR_MODE_VISIBLE:
- gtk_widget_show (GTK_WIDGET (cur->data));
- last = NULL;
- visible = FALSE;
- break;
- case SEPARATOR_MODE_HIDDEN:
- gtk_widget_hide (GTK_WIDGET (cur->data));
- break;
- case SEPARATOR_MODE_SMART:
- if (visible)
- {
- gtk_widget_show (GTK_WIDGET (cur->data));
- last = cur;
- visible = FALSE;
- }
- else
- gtk_widget_hide (GTK_WIDGET (cur->data));
- break;
- }
- }
- else if (gtk_widget_get_visible (cur->data))
- {
- last = NULL;
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-
- if (GTK_IS_TEAROFF_MENU_ITEM (cur->data) || cur->data == filler)
- visible = FALSE;
- else
- {
- visible = TRUE;
- empty = FALSE;
- }
-
-G_GNUC_END_IGNORE_DEPRECATIONS
-
- }
-
- cur = cur->next;
- }
-
- if (last)
- gtk_widget_hide (GTK_WIDGET (last->data));
-
- if (GTK_IS_MENU (parent))
- {
- GtkWidget *item;
-
- item = gtk_menu_get_attach_widget (GTK_MENU (parent));
- if (GTK_IS_MENU_ITEM (item))
- _gtk_action_sync_menu_visible (NULL, item, empty);
- if (GTK_IS_WIDGET (filler))
- {
- if (empty)
- gtk_widget_show (filler);
- else
- gtk_widget_hide (filler);
- }
- }
-
- g_list_free (children);
- }
-}
-
-static void
-update_node (GtkUIManager *manager,
- GNode *node,
- gboolean in_popup,
- gboolean popup_accels)
-{
- Node *info;
- GNode *child;
- GtkAction *action;
- const gchar *action_name;
- NodeUIReference *ref;
-
-#ifdef DEBUG_UI_MANAGER
- GList *tmp;
-#endif
-
- g_return_if_fail (node != NULL);
- g_return_if_fail (NODE_INFO (node) != NULL);
-
- info = NODE_INFO (node);
-
- if (!info->dirty)
- return;
-
- if (info->type == NODE_TYPE_POPUP)
- {
- in_popup = TRUE;
- popup_accels = info->popup_accels;
- }
-
-#ifdef DEBUG_UI_MANAGER
- g_print ("update_node name=%s dirty=%d popup %d (",
- info->name, info->dirty, in_popup);
- for (tmp = info->uifiles; tmp != NULL; tmp = tmp->next)
- {
- NodeUIReference *ref = tmp->data;
- g_print("%s:%u", g_quark_to_string (ref->action_quark), ref->merge_id);
- if (tmp->next)
- g_print (", ");
- }
- g_print (")\n");
-#endif
-
- if (info->uifiles == NULL) {
- /* We may need to remove this node.
- * This must be done in post order
- */
- goto recurse_children;
- }
-
- ref = info->uifiles->data;
- action_name = g_quark_to_string (ref->action_quark);
- action = get_action_by_name (manager, action_name);
-
- info->dirty = FALSE;
-
- /* Check if the node doesn't have an action and must have an action */
- if (action == NULL &&
- info->type != NODE_TYPE_ROOT &&
- info->type != NODE_TYPE_MENUBAR &&
- info->type != NODE_TYPE_TOOLBAR &&
- info->type != NODE_TYPE_POPUP &&
- info->type != NODE_TYPE_SEPARATOR &&
- info->type != NODE_TYPE_MENU_PLACEHOLDER &&
- info->type != NODE_TYPE_TOOLBAR_PLACEHOLDER)
- {
- g_warning ("%s: missing action %s", info->name, action_name);
-
- return;
- }
-
- if (action)
- gtk_action_set_accel_group (action, manager->private_data->accel_group);
-
- /* If the widget already has a proxy and the action hasn't changed, then
- * we only have to update the tearoff menu items.
- */
- if (info->proxy != NULL && action == info->action)
- {
- if (info->type == NODE_TYPE_MENU)
- {
- GtkWidget *menu;
- GList *siblings;
-
- if (GTK_IS_MENU (info->proxy))
- menu = info->proxy;
- else
- menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (info->proxy));
- siblings = gtk_container_get_children (GTK_CONTAINER (menu));
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-
- if (siblings != NULL && GTK_IS_TEAROFF_MENU_ITEM (siblings->data))
- {
- if (manager->private_data->add_tearoffs && !in_popup)
- gtk_widget_show (GTK_WIDGET (siblings->data));
- else
- gtk_widget_hide (GTK_WIDGET (siblings->data));
- }
-
-G_GNUC_END_IGNORE_DEPRECATIONS
-
- g_list_free (siblings);
- }
-
- goto recurse_children;
- }
-
- switch (info->type)
- {
- case NODE_TYPE_MENUBAR:
- if (info->proxy == NULL)
- {
- info->proxy = gtk_menu_bar_new ();
- g_object_ref_sink (info->proxy);
- gtk_widget_set_name (info->proxy, info->name);
- gtk_widget_show (info->proxy);
- g_signal_emit (manager, ui_manager_signals[ADD_WIDGET], 0, info->proxy);
- }
- break;
- case NODE_TYPE_POPUP:
- if (info->proxy == NULL)
- {
- info->proxy = gtk_menu_new ();
- g_object_ref_sink (info->proxy);
- }
- gtk_widget_set_name (info->proxy, info->name);
- break;
- case NODE_TYPE_MENU:
- {
- GtkWidget *prev_submenu = NULL;
- GtkWidget *menu = NULL;
- GList *siblings;
-
- /* remove the proxy if it is of the wrong type ... */
- if (info->proxy &&
- G_OBJECT_TYPE (info->proxy) != GTK_ACTION_GET_CLASS (action)->menu_item_type)
- {
- if (GTK_IS_MENU_ITEM (info->proxy))
- {
- prev_submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (info->proxy));
- if (prev_submenu)
- {
- g_object_ref (prev_submenu);
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (info->proxy), NULL);
- }
- }
-
- gtk_activatable_set_related_action (GTK_ACTIVATABLE (info->proxy), NULL);
- gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)),
- info->proxy);
- g_object_unref (info->proxy);
- info->proxy = NULL;
- }
-
- /* create proxy if needed ... */
- if (info->proxy == NULL)
- {
- /* ... if the action already provides a menu, then use
- * that menu instead of creating an empty one
- */
- if ((NODE_INFO (node->parent)->type == NODE_TYPE_TOOLITEM ||
- NODE_INFO (node->parent)->type == NODE_TYPE_MENUITEM) &&
- GTK_ACTION_GET_CLASS (action)->create_menu)
- {
- menu = gtk_action_create_menu (action);
- }
-
- if (!menu)
- {
- GtkWidget *tearoff;
- GtkWidget *filler;
-
- menu = gtk_menu_new ();
- gtk_widget_set_name (menu, info->name);
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- tearoff = gtk_tearoff_menu_item_new ();
-G_GNUC_END_IGNORE_DEPRECATIONS
-
- gtk_widget_set_no_show_all (tearoff, TRUE);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), tearoff);
- filler = gtk_menu_item_new_with_label (_("Empty"));
- g_object_set_data (G_OBJECT (filler),
- I_("gtk-empty-menu-item"),
- GINT_TO_POINTER (TRUE));
- gtk_widget_set_sensitive (filler, FALSE);
- gtk_widget_set_no_show_all (filler, TRUE);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), filler);
- }
-
- if (NODE_INFO (node->parent)->type == NODE_TYPE_TOOLITEM)
- {
- info->proxy = menu;
- g_object_ref_sink (info->proxy);
- gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (NODE_INFO (node->parent)->proxy),
- menu);
- }
- else
- {
- GtkWidget *menushell;
- gint pos;
-
- if (find_menu_position (node, &menushell, &pos))
- {
- info->proxy = gtk_action_create_menu_item (action);
- g_object_ref_sink (info->proxy);
- g_signal_connect (info->proxy, "notify::visible",
- G_CALLBACK (update_smart_separators), NULL);
- gtk_widget_set_name (info->proxy, info->name);
-
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (info->proxy), menu);
- gtk_menu_shell_insert (GTK_MENU_SHELL (menushell), info->proxy, pos);
- }
- }
- }
- else
- gtk_activatable_set_related_action (GTK_ACTIVATABLE (info->proxy), action);
-
- if (prev_submenu)
- {
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (info->proxy),
- prev_submenu);
- g_object_unref (prev_submenu);
- }
-
- if (GTK_IS_MENU (info->proxy))
- menu = info->proxy;
- else
- menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (info->proxy));
-
- siblings = gtk_container_get_children (GTK_CONTAINER (menu));
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-
- if (siblings != NULL && GTK_IS_TEAROFF_MENU_ITEM (siblings->data))
- {
- if (manager->private_data->add_tearoffs && !in_popup)
- gtk_widget_show (GTK_WIDGET (siblings->data));
- else
- gtk_widget_hide (GTK_WIDGET (siblings->data));
- }
-
-G_GNUC_END_IGNORE_DEPRECATIONS
-
- g_list_free (siblings);
- }
- break;
- case NODE_TYPE_UNDECIDED:
- g_warning ("found undecided node!");
- break;
- case NODE_TYPE_ROOT:
- break;
- case NODE_TYPE_TOOLBAR:
- if (info->proxy == NULL)
- {
- info->proxy = gtk_toolbar_new ();
- g_object_ref_sink (info->proxy);
- gtk_widget_set_name (info->proxy, info->name);
- gtk_widget_show (info->proxy);
- g_signal_emit (manager, ui_manager_signals[ADD_WIDGET], 0, info->proxy);
- }
- break;
- case NODE_TYPE_MENU_PLACEHOLDER:
- /* create menu items for placeholders if necessary ... */
- if (!GTK_IS_SEPARATOR_MENU_ITEM (info->proxy) ||
- !GTK_IS_SEPARATOR_MENU_ITEM (info->extra))
- {
- if (info->proxy)
- {
- gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)),
- info->proxy);
- g_object_unref (info->proxy);
- info->proxy = NULL;
- }
- if (info->extra)
- {
- gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->extra)),
- info->extra);
- g_object_unref (info->extra);
- info->extra = NULL;
- }
- }
- if (info->proxy == NULL)
- {
- GtkWidget *menushell;
- gint pos;
-
- if (find_menu_position (node, &menushell, &pos))
- {
- info->proxy = gtk_separator_menu_item_new ();
- g_object_ref_sink (info->proxy);
- g_object_set_data (G_OBJECT (info->proxy),
- I_("gtk-separator-mode"),
- GINT_TO_POINTER (SEPARATOR_MODE_HIDDEN));
- gtk_widget_set_no_show_all (info->proxy, TRUE);
- gtk_menu_shell_insert (GTK_MENU_SHELL (menushell),
- NODE_INFO (node)->proxy, pos);
-
- info->extra = gtk_separator_menu_item_new ();
- g_object_ref_sink (info->extra);
- g_object_set_data (G_OBJECT (info->extra),
- I_("gtk-separator-mode"),
- GINT_TO_POINTER (SEPARATOR_MODE_HIDDEN));
- gtk_widget_set_no_show_all (info->extra, TRUE);
- gtk_menu_shell_insert (GTK_MENU_SHELL (menushell),
- NODE_INFO (node)->extra, pos + 1);
- }
- }
- break;
- case NODE_TYPE_TOOLBAR_PLACEHOLDER:
- /* create toolbar items for placeholders if necessary ... */
- if (!GTK_IS_SEPARATOR_TOOL_ITEM (info->proxy) ||
- !GTK_IS_SEPARATOR_TOOL_ITEM (info->extra))
- {
- if (info->proxy)
- {
- gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)),
- info->proxy);
- g_object_unref (info->proxy);
- info->proxy = NULL;
- }
- if (info->extra)
- {
- gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->extra)),
- info->extra);
- g_object_unref (info->extra);
- info->extra = NULL;
- }
- }
- if (info->proxy == NULL)
- {
- GtkWidget *toolbar;
- gint pos;
- GtkToolItem *item;
-
- if (find_toolbar_position (node, &toolbar, &pos))
- {
- item = gtk_separator_tool_item_new ();
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, pos);
- info->proxy = GTK_WIDGET (item);
- g_object_ref_sink (info->proxy);
- g_object_set_data (G_OBJECT (info->proxy),
- I_("gtk-separator-mode"),
- GINT_TO_POINTER (SEPARATOR_MODE_HIDDEN));
- gtk_widget_set_no_show_all (info->proxy, TRUE);
-
- item = gtk_separator_tool_item_new ();
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, pos+1);
- info->extra = GTK_WIDGET (item);
- g_object_ref_sink (info->extra);
- g_object_set_data (G_OBJECT (info->extra),
- I_("gtk-separator-mode"),
- GINT_TO_POINTER (SEPARATOR_MODE_HIDDEN));
- gtk_widget_set_no_show_all (info->extra, TRUE);
- }
- }
- break;
- case NODE_TYPE_MENUITEM:
- /* remove the proxy if it is of the wrong type ... */
- if (info->proxy &&
- G_OBJECT_TYPE (info->proxy) != GTK_ACTION_GET_CLASS (action)->menu_item_type)
- {
- g_signal_handlers_disconnect_by_func (info->proxy,
- G_CALLBACK (update_smart_separators),
- NULL);
- gtk_activatable_set_related_action (GTK_ACTIVATABLE (info->proxy), NULL);
- gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)),
- info->proxy);
- g_object_unref (info->proxy);
- info->proxy = NULL;
- }
- /* create proxy if needed ... */
- if (info->proxy == NULL)
- {
- GtkWidget *menushell;
- gint pos;
-
- if (find_menu_position (node, &menushell, &pos))
- {
- info->proxy = gtk_action_create_menu_item (action);
- g_object_ref_sink (info->proxy);
- gtk_widget_set_name (info->proxy, info->name);
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-
- if (info->always_show_image_set &&
- GTK_IS_IMAGE_MENU_ITEM (info->proxy))
- gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (info->proxy),
- info->always_show_image);
-
- G_GNUC_END_IGNORE_DEPRECATIONS;
-
- gtk_menu_shell_insert (GTK_MENU_SHELL (menushell),
- info->proxy, pos);
- }
- }
- else
- {
- g_signal_handlers_disconnect_by_func (info->proxy,
- G_CALLBACK (update_smart_separators),
- NULL);
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (info->proxy), NULL);
- gtk_activatable_set_related_action (GTK_ACTIVATABLE (info->proxy), action);
- }
-
- if (info->proxy)
- {
- g_signal_connect (info->proxy, "notify::visible",
- G_CALLBACK (update_smart_separators), NULL);
- if (in_popup && !popup_accels)
- {
- /* don't show accels in popups */
- GtkWidget *child = gtk_bin_get_child (GTK_BIN (info->proxy));
- if (GTK_IS_ACCEL_LABEL (child))
- g_object_set (child, "accel-closure", NULL, NULL);
- }
- }
-
- break;
- case NODE_TYPE_TOOLITEM:
- /* remove the proxy if it is of the wrong type ... */
- if (info->proxy &&
- G_OBJECT_TYPE (info->proxy) != GTK_ACTION_GET_CLASS (action)->toolbar_item_type)
- {
- g_signal_handlers_disconnect_by_func (info->proxy,
- G_CALLBACK (update_smart_separators),
- NULL);
- gtk_activatable_set_related_action (GTK_ACTIVATABLE (info->proxy), NULL);
- gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)),
- info->proxy);
- g_object_unref (info->proxy);
- info->proxy = NULL;
- }
- /* create proxy if needed ... */
- if (info->proxy == NULL)
- {
- GtkWidget *toolbar;
- gint pos;
-
- if (find_toolbar_position (node, &toolbar, &pos))
- {
- info->proxy = gtk_action_create_tool_item (action);
- g_object_ref_sink (info->proxy);
- gtk_widget_set_name (info->proxy, info->name);
-
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar),
- GTK_TOOL_ITEM (info->proxy), pos);
- }
- }
- else
- {
- g_signal_handlers_disconnect_by_func (info->proxy,
- G_CALLBACK (update_smart_separators),
- NULL);
- gtk_activatable_set_related_action (GTK_ACTIVATABLE (info->proxy), action);
- }
-
- if (info->proxy)
- {
- g_signal_connect (info->proxy, "notify::visible",
- G_CALLBACK (update_smart_separators), NULL);
- }
- break;
- case NODE_TYPE_SEPARATOR:
- if (NODE_INFO (node->parent)->type == NODE_TYPE_TOOLBAR ||
- NODE_INFO (node->parent)->type == NODE_TYPE_TOOLBAR_PLACEHOLDER)
- {
- GtkWidget *toolbar;
- gint pos;
- gint separator_mode;
- GtkToolItem *item;
-
- if (GTK_IS_SEPARATOR_TOOL_ITEM (info->proxy))
- {
- gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)),
- info->proxy);
- g_object_unref (info->proxy);
- info->proxy = NULL;
- }
-
- if (find_toolbar_position (node, &toolbar, &pos))
- {
- item = gtk_separator_tool_item_new ();
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, pos);
- info->proxy = GTK_WIDGET (item);
- g_object_ref_sink (info->proxy);
- gtk_widget_set_no_show_all (info->proxy, TRUE);
- if (info->expand)
- {
- gtk_tool_item_set_expand (GTK_TOOL_ITEM (item), TRUE);
- gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (item), FALSE);
- separator_mode = SEPARATOR_MODE_VISIBLE;
- }
- else
- separator_mode = SEPARATOR_MODE_SMART;
-
- g_object_set_data (G_OBJECT (info->proxy),
- I_("gtk-separator-mode"),
- GINT_TO_POINTER (separator_mode));
- gtk_widget_show (info->proxy);
- }
- }
- else
- {
- GtkWidget *menushell;
- gint pos;
-
- if (GTK_IS_SEPARATOR_MENU_ITEM (info->proxy))
- {
- gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)),
- info->proxy);
- g_object_unref (info->proxy);
- info->proxy = NULL;
- }
-
- if (find_menu_position (node, &menushell, &pos))
- {
- info->proxy = gtk_separator_menu_item_new ();
- g_object_ref_sink (info->proxy);
- gtk_widget_set_no_show_all (info->proxy, TRUE);
- g_object_set_data (G_OBJECT (info->proxy),
- I_("gtk-separator-mode"),
- GINT_TO_POINTER (SEPARATOR_MODE_SMART));
- gtk_menu_shell_insert (GTK_MENU_SHELL (menushell),
- info->proxy, pos);
- gtk_widget_show (info->proxy);
- }
- }
- break;
- case NODE_TYPE_ACCELERATOR:
- gtk_action_connect_accelerator (action);
- break;
- }
-
- if (action)
- g_object_ref (action);
- if (info->action)
- g_object_unref (info->action);
- info->action = action;
-
- recurse_children:
- /* process children */
- child = node->children;
- while (child)
- {
- GNode *current;
-
- current = child;
- child = current->next;
- update_node (manager, current, in_popup, popup_accels);
- }
-
- if (info->proxy)
- {
- if (info->type == NODE_TYPE_MENU && GTK_IS_MENU_ITEM (info->proxy))
- update_smart_separators (gtk_menu_item_get_submenu (GTK_MENU_ITEM (info->proxy)));
- else if (info->type == NODE_TYPE_MENU ||
- info->type == NODE_TYPE_TOOLBAR ||
- info->type == NODE_TYPE_POPUP)
- update_smart_separators (info->proxy);
- }
-
- /* handle cleanup of dead nodes */
- if (node->children == NULL && info->uifiles == NULL)
- {
- if (info->proxy)
- gtk_widget_destroy (info->proxy);
- if (info->extra)
- gtk_widget_destroy (info->extra);
- if (info->type == NODE_TYPE_ACCELERATOR && info->action != NULL)
- gtk_action_disconnect_accelerator (info->action);
- free_node (node);
- g_node_destroy (node);
- }
-}
-
-static gboolean
-do_updates (GtkUIManager *manager)
-{
- /* this function needs to check through the tree for dirty nodes.
- * For such nodes, it needs to do the following:
- *
- * 1) check if they are referenced by any loaded UI files anymore.
- * In which case, the proxy widget should be destroyed, unless
- * there are any subnodes.
- *
- * 2) lookup the action for this node again. If it is different to
- * the current one (or if no previous action has been looked up),
- * the proxy is reconnected to the new action (or a new proxy widget
- * is created and added to the parent container).
- */
- update_node (manager, manager->private_data->root_node, FALSE, FALSE);
-
- manager->private_data->update_tag = 0;
-
- return FALSE;
-}
-
-static gboolean
-do_updates_idle (GtkUIManager *manager)
-{
- do_updates (manager);
-
- return FALSE;
-}
-
-static void
-queue_update (GtkUIManager *manager)
-{
- if (manager->private_data->update_tag != 0)
- return;
-
- manager->private_data->update_tag = gdk_threads_add_idle (
- (GSourceFunc)do_updates_idle,
- manager);
-}
-
-
-/**
- * gtk_ui_manager_ensure_update:
- * @manager: a #GtkUIManager
- *
- * Makes sure that all pending updates to the UI have been completed.
- *
- * This may occasionally be necessary, since #GtkUIManager updates the
- * UI in an idle function. A typical example where this function is
- * useful is to enforce that the menubar and toolbar have been added to
- * the main window before showing it:
- * |[
- * gtk_container_add (GTK_CONTAINER (window), vbox);
- * g_signal_connect (merge, "add-widget",
- * G_CALLBACK (add_widget), vbox);
- * gtk_ui_manager_add_ui_from_file (merge, "my-menus");
- * gtk_ui_manager_add_ui_from_file (merge, "my-toolbars");
- * gtk_ui_manager_ensure_update (merge);
- * gtk_widget_show (window);
- * ]|
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-void
-gtk_ui_manager_ensure_update (GtkUIManager *manager)
-{
- if (manager->private_data->update_tag != 0)
- {
- g_source_remove (manager->private_data->update_tag);
- do_updates (manager);
- }
-}
-
-static gboolean
-dirty_traverse_func (GNode *node,
- gpointer data)
-{
- NODE_INFO (node)->dirty = TRUE;
- return FALSE;
-}
-
-static void
-dirty_all_nodes (GtkUIManager *manager)
-{
- g_node_traverse (manager->private_data->root_node,
- G_PRE_ORDER, G_TRAVERSE_ALL, -1,
- dirty_traverse_func, NULL);
- queue_update (manager);
-}
-
-static void
-mark_node_dirty (GNode *node)
-{
- GNode *p;
-
- /* FIXME could optimize this */
- for (p = node; p; p = p->parent)
- NODE_INFO (p)->dirty = TRUE;
-}
-
-static const gchar *
-open_tag_format (NodeType type)
-{
- switch (type)
- {
- case NODE_TYPE_UNDECIDED: return "%*s<UNDECIDED";
- case NODE_TYPE_ROOT: return "%*s<ui";
- case NODE_TYPE_MENUBAR: return "%*s<menubar";
- case NODE_TYPE_MENU: return "%*s<menu";
- case NODE_TYPE_TOOLBAR: return "%*s<toolbar";
- case NODE_TYPE_MENU_PLACEHOLDER:
- case NODE_TYPE_TOOLBAR_PLACEHOLDER: return "%*s<placeholder";
- case NODE_TYPE_POPUP: return "%*s<popup";
- case NODE_TYPE_MENUITEM: return "%*s<menuitem";
- case NODE_TYPE_TOOLITEM: return "%*s<toolitem";
- case NODE_TYPE_SEPARATOR: return "%*s<separator";
- case NODE_TYPE_ACCELERATOR: return "%*s<accelerator";
- default: return NULL;
- }
-}
-
-static const gchar *
-close_tag_format (NodeType type)
-{
- switch (type)
- {
- case NODE_TYPE_UNDECIDED: return "%*s</UNDECIDED>\n";
- case NODE_TYPE_ROOT: return "%*s</ui>\n";
- case NODE_TYPE_MENUBAR: return "%*s</menubar>\n";
- case NODE_TYPE_MENU: return "%*s</menu>\n";
- case NODE_TYPE_TOOLBAR: return "%*s</toolbar>\n";
- case NODE_TYPE_MENU_PLACEHOLDER:
- case NODE_TYPE_TOOLBAR_PLACEHOLDER: return "%*s</placeholder>\n";
- case NODE_TYPE_POPUP: return "%*s</popup>\n";
- default: return NULL;
- }
-}
-
-static void
-print_node (GtkUIManager *manager,
- GNode *node,
- gint indent_level,
- GString *buffer)
-{
- Node *mnode;
- GNode *child;
- const gchar *open_fmt;
- const gchar *close_fmt;
-
- mnode = node->data;
-
- open_fmt = open_tag_format (mnode->type);
- close_fmt = close_tag_format (mnode->type);
-
- g_string_append_printf (buffer, open_fmt, indent_level, "");
-
- if (mnode->type != NODE_TYPE_ROOT)
- {
- if (mnode->name)
- g_string_append_printf (buffer, " name=\"%s\"", mnode->name);
-
- if (mnode->action_name)
- g_string_append_printf (buffer, " action=\"%s\"",
- g_quark_to_string (mnode->action_name));
- }
-
- g_string_append (buffer, close_fmt ? ">\n" : "/>\n");
-
- for (child = node->children; child != NULL; child = child->next)
- print_node (manager, child, indent_level + 2, buffer);
-
- if (close_fmt)
- g_string_append_printf (buffer, close_fmt, indent_level, "");
-}
-
-static gboolean
-gtk_ui_manager_buildable_custom_tag_start (GtkBuildable *buildable,
- GtkBuilder *builder,
- GObject *child,
- const gchar *tagname,
- GMarkupParser *parser,
- gpointer *data)
-{
- if (child)
- return FALSE;
-
- if (strcmp (tagname, "ui") == 0)
- {
- ParseContext *ctx;
-
- ctx = g_new0 (ParseContext, 1);
- ctx->state = STATE_START;
- ctx->manager = GTK_UI_MANAGER (buildable);
- ctx->current = NULL;
- ctx->merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (buildable));
-
- *data = ctx;
- *parser = ui_parser;
-
- return TRUE;
- }
-
- return FALSE;
-
-}
-
-static void
-gtk_ui_manager_buildable_custom_tag_end (GtkBuildable *buildable,
- GtkBuilder *builder,
- GObject *child,
- const gchar *tagname,
- gpointer *data)
-{
- queue_update (GTK_UI_MANAGER (buildable));
- g_object_notify (G_OBJECT (buildable), "ui");
- g_free (data);
-}
-
-/**
- * gtk_ui_manager_get_ui:
- * @manager: a #GtkUIManager
- *
- * Creates a <link linkend="XML-UI">UI definition</link> of the merged UI.
- *
- * Return value: A newly allocated string containing an XML representation of
- * the merged UI.
- *
- * Since: 2.4
- *
- * Deprecated: 3.10
- **/
-gchar *
-gtk_ui_manager_get_ui (GtkUIManager *manager)
-{
- GString *buffer;
-
- buffer = g_string_new (NULL);
-
- gtk_ui_manager_ensure_update (manager);
-
- print_node (manager, manager->private_data->root_node, 0, buffer);
-
- return g_string_free (buffer, FALSE);
-}
+++ /dev/null
-/*
- * GTK - The GIMP Toolkit
- * Copyright (C) 1998, 1999 Red Hat, Inc.
- * All rights reserved.
- *
- * This Library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This Library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Author: James Henstridge <james@daa.com.au>
- *
- * Modified by the GTK+ Team and others 2003. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#ifndef __GTK_UI_MANAGER_H__
-#define __GTK_UI_MANAGER_H__
-
-#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
-#error "Only <gtk/gtk.h> can be included directly."
-#endif
-
-#include <gtk/gtkaccelgroup.h>
-#include <gtk/gtkwidget.h>
-#include <gtk/gtkaction.h>
-#include <gtk/gtkactiongroup.h>
-
-G_BEGIN_DECLS
-
-#define GTK_TYPE_UI_MANAGER (gtk_ui_manager_get_type ())
-#define GTK_UI_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_UI_MANAGER, GtkUIManager))
-#define GTK_UI_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_UI_MANAGER, GtkUIManagerClass))
-#define GTK_IS_UI_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_UI_MANAGER))
-#define GTK_IS_UI_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_UI_MANAGER))
-#define GTK_UI_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_UI_MANAGER, GtkUIManagerClass))
-
-typedef struct _GtkUIManager GtkUIManager;
-typedef struct _GtkUIManagerClass GtkUIManagerClass;
-typedef struct _GtkUIManagerPrivate GtkUIManagerPrivate;
-
-
-struct _GtkUIManager {
- GObject parent;
-
- /*< private >*/
- GtkUIManagerPrivate *private_data;
-};
-
-struct _GtkUIManagerClass {
- GObjectClass parent_class;
-
- /* Signals */
- void (* add_widget) (GtkUIManager *manager,
- GtkWidget *widget);
- void (* actions_changed) (GtkUIManager *manager);
- void (* connect_proxy) (GtkUIManager *manager,
- GtkAction *action,
- GtkWidget *proxy);
- void (* disconnect_proxy) (GtkUIManager *manager,
- GtkAction *action,
- GtkWidget *proxy);
- void (* pre_activate) (GtkUIManager *manager,
- GtkAction *action);
- void (* post_activate) (GtkUIManager *manager,
- GtkAction *action);
-
- /* Virtual functions */
- GtkWidget * (* get_widget) (GtkUIManager *manager,
- const gchar *path);
- GtkAction * (* get_action) (GtkUIManager *manager,
- const gchar *path);
-
- /* Padding for future expansion */
- void (*_gtk_reserved1) (void);
- void (*_gtk_reserved2) (void);
- void (*_gtk_reserved3) (void);
- void (*_gtk_reserved4) (void);
-};
-
-/**
- * GtkUIManagerItemType:
- * @GTK_UI_MANAGER_AUTO: Pick the type of the UI element according to context.
- * @GTK_UI_MANAGER_MENUBAR: Create a menubar.
- * @GTK_UI_MANAGER_MENU: Create a menu.
- * @GTK_UI_MANAGER_TOOLBAR: Create a toolbar.
- * @GTK_UI_MANAGER_PLACEHOLDER: Insert a placeholder.
- * @GTK_UI_MANAGER_POPUP: Create a popup menu.
- * @GTK_UI_MANAGER_MENUITEM: Create a menuitem.
- * @GTK_UI_MANAGER_TOOLITEM: Create a toolitem.
- * @GTK_UI_MANAGER_SEPARATOR: Create a separator.
- * @GTK_UI_MANAGER_ACCELERATOR: Install an accelerator.
- * @GTK_UI_MANAGER_POPUP_WITH_ACCELS: Same as %GTK_UI_MANAGER_POPUP, but the
- * actions' accelerators are shown.
- *
- * These enumeration values are used by gtk_ui_manager_add_ui() to determine
- * what UI element to create.
- *
- * Deprecated: 3.10
- */
-typedef enum {
- GTK_UI_MANAGER_AUTO = 0,
- GTK_UI_MANAGER_MENUBAR = 1 << 0,
- GTK_UI_MANAGER_MENU = 1 << 1,
- GTK_UI_MANAGER_TOOLBAR = 1 << 2,
- GTK_UI_MANAGER_PLACEHOLDER = 1 << 3,
- GTK_UI_MANAGER_POPUP = 1 << 4,
- GTK_UI_MANAGER_MENUITEM = 1 << 5,
- GTK_UI_MANAGER_TOOLITEM = 1 << 6,
- GTK_UI_MANAGER_SEPARATOR = 1 << 7,
- GTK_UI_MANAGER_ACCELERATOR = 1 << 8,
- GTK_UI_MANAGER_POPUP_WITH_ACCELS = 1 << 9
-} GtkUIManagerItemType;
-
-GDK_DEPRECATED_IN_3_10
-GType gtk_ui_manager_get_type (void) G_GNUC_CONST;
-GDK_DEPRECATED_IN_3_10
-GtkUIManager *gtk_ui_manager_new (void);
-GDK_DEPRECATED_IN_3_4
-void gtk_ui_manager_set_add_tearoffs (GtkUIManager *manager,
- gboolean add_tearoffs);
-GDK_DEPRECATED_IN_3_4
-gboolean gtk_ui_manager_get_add_tearoffs (GtkUIManager *manager);
-
-GDK_DEPRECATED_IN_3_10
-void gtk_ui_manager_insert_action_group (GtkUIManager *manager,
- GtkActionGroup *action_group,
- gint pos);
-GDK_DEPRECATED_IN_3_10
-void gtk_ui_manager_remove_action_group (GtkUIManager *manager,
- GtkActionGroup *action_group);
-GDK_DEPRECATED_IN_3_10
-GList *gtk_ui_manager_get_action_groups (GtkUIManager *manager);
-GDK_DEPRECATED_IN_3_10
-GtkAccelGroup *gtk_ui_manager_get_accel_group (GtkUIManager *manager);
-GDK_DEPRECATED_IN_3_10
-GtkWidget *gtk_ui_manager_get_widget (GtkUIManager *manager,
- const gchar *path);
-GDK_DEPRECATED_IN_3_10
-GSList *gtk_ui_manager_get_toplevels (GtkUIManager *manager,
- GtkUIManagerItemType types);
-GDK_DEPRECATED_IN_3_10
-GtkAction *gtk_ui_manager_get_action (GtkUIManager *manager,
- const gchar *path);
-GDK_DEPRECATED_IN_3_10
-guint gtk_ui_manager_add_ui_from_string (GtkUIManager *manager,
- const gchar *buffer,
- gssize length,
- GError **error);
-GDK_DEPRECATED_IN_3_10
-guint gtk_ui_manager_add_ui_from_file (GtkUIManager *manager,
- const gchar *filename,
- GError **error);
-GDK_DEPRECATED_IN_3_10
-guint gtk_ui_manager_add_ui_from_resource(GtkUIManager *manager,
- const gchar *resource_path,
- GError **error);
-GDK_DEPRECATED_IN_3_10
-void gtk_ui_manager_add_ui (GtkUIManager *manager,
- guint merge_id,
- const gchar *path,
- const gchar *name,
- const gchar *action,
- GtkUIManagerItemType type,
- gboolean top);
-GDK_DEPRECATED_IN_3_10
-void gtk_ui_manager_remove_ui (GtkUIManager *manager,
- guint merge_id);
-GDK_DEPRECATED_IN_3_10
-gchar *gtk_ui_manager_get_ui (GtkUIManager *manager);
-GDK_DEPRECATED_IN_3_10
-void gtk_ui_manager_ensure_update (GtkUIManager *manager);
-GDK_DEPRECATED_IN_3_10
-guint gtk_ui_manager_new_merge_id (GtkUIManager *manager);
-
-G_END_DECLS
-
-#endif /* __GTK_UI_MANAGER_H__ */
#include "gtkclipboard.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkcssnumbervalueprivate.h"
-#include "gtkiconfactory.h"
+#include "deprecated/gtkiconfactory.h"
#include "gtkintl.h"
#include "gtkmarshalers.h"
#include "gtkselectionprivate.h"
#include "gtkmain.h"
#include "gtkmnemonichash.h"
#include "gtkmenubar.h"
-#include "gtkiconfactory.h"
+#include "deprecated/gtkiconfactory.h"
#include "gtkicontheme.h"
#include "gtkmarshalers.h"
#include "gtkplug.h"